Getting java.net.SocketException: Malformed reply from SOCKS server exception for the following socket creation.I am not using any SOCKS Server & and it is just a stand alone program, this the starting line & getting exception here only.I am using reflection API also.
public static String tcpSend(String ip, int port, int timeout, String content)
{
try
{
clientSocket = new Socket(ip, port);
.....
}
.....
}
Calling from other method like the following:
SendReceiveCanMessage.tcpSend("localhost", 8000, 5000,"start");
The folling is the complete stacktrace.
java.net.SocketException: Malformed reply from SOCKS server
at java.net.SocksSocketImpl.readSocksReply(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at com.cognizant.vehiclespy.SendReceiveCanMessage.tcpSend(SendReceiveCanMessage.java:19)
at Executer.executeTest3_12(Executer.java:672)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.cognizant.controller.SupervisoryControl.execute(SupervisoryControl.java:111)
at supervisorycontrol.SupervisoryControlView$ExecuteThread.run(SupervisoryControlView.java:466)
Somewhere you have the system property 'socksProxyHost' set. Find it and nuke it.
Related
In restassured am getting the "java.net.ConnectException: Connection refused: connect" if I execute the below function tu3 from a different class. If I call the function from parent class, it is successfully executed. Please let me know how to correct this.
#Parameters({"Param 1","Param 2"})
#Test
public void tu3(#Optional String la, #Optional int StatusCode ) throws
IOException
System.out.println("Test"+la);
System.out.println(URI);
given().pathParam("user_ID", la)
.when().delete("/{user_ID}")
.then().statusCode(StatusCode);
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
here is the problem i guess userid is double quotes
.when().delete("/{user_ID}")
Correct line should be
.when().delete("URL/"+user_ID)
Your URL should be URL/1 where 1 is user_id, not URL/{user_id}
You should pass userID to be deleted
In .delete you should provide whole API URL
I'm having some issues for creating a simple socket, I'm new to this kind of stuff sorry for a simple question thanks. I tried to follow some tutorial for creating Sockets in java and tried this so far
try {
Socket chatSocket = new Socket("127.0.0.1", 4242);
System.out.println("connection established");
}
catch (IOException e) {
e.printStackTrace();
}
I'm getting this kind of error
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at application.main.main(main.java:15)
and when I try to access my localhost from my browser I see this error
The connection to '127.0.0.1' failed.
Error: ConnectionRefused (0x274d).
System.Net.Sockets.SocketException No connection could be made because the
target machine actively refused it 127.0.0.1:4242
I have no idea what is happening because, just followed what the tutorial does. I think the issue is on my local machine but I have no idea what is making the connection refuse
I have created a service that opens a lots of remote resources; for a lot, i mean over 200k / day, but i think that less than 1000 connections are opened at the same time. After i connect to the remote resource, i open an input stream to get the file content.
Sometimes i get the following exception
java.net.BindException: Address already in use: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sitodove.varie.ExternalLinksChecker.getWebPage(ExternalLinksChecker.java:121)
at sitodove.varie.ExternalLinksChecker.run(ExternalLinksChecker.java:37)
This service starts correctly, opening just a few ports for limited needs because it needs to offer some services. While it is running, i get the above exception, what may be the cause?
A port is already being used and you try to bind it again. Check in your application if your are not trying to use a port twice.
Probably, you're trying to open a port that is already open.
open the terminal an type telnet to see if that port is already open. ie.
telnet localhost 9889
Trying ::1...
telnet: connect to address ::1: Connection refused
if this command returns Connection refused, that means the port is free.
I'm pretty new to java , actually I have just started learning it
I tried to do an exercise and the exercise was to read the first five lines of a webpage
for start I wrote this code :
import java.io.* ;
import java.net.URL ;
class testcode {
public static void main(String[] args) throws Exception {
URL address = new URL("http://www.yahoo.com/") ;
InputStream is = address.openStream() ;
InputStreamReader isr = new InputStreamReader(is) ;
BufferedReader reader = new BufferedReader(isr) ;
String line = reader.readLine() ;
}
}
but when I run this piece of code through Eclipse , I get this :
Exception in thread "main" java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at test.testcode.main(testcode.java:10)
Why is this happening !?
and ofcourse when I dont put the throws Exception part at the begining I get the malformed url exception !
PS : my internet connection works just fine !
Can Somebody please help me and explain why is this happening while doing that ?
I have a pretty good c++ background so feel free to explain as deep as you can :D
It seems like your program can't connect to the URL. Are u using internet behind proxy? If so, then make sure ur program is configured accordingly. One way is to use this code:
System.setProperty("http.proxyHost", "proxy.mydomain.com");
System.setPropery("http.proxyPort", "8080");
I am not able to connect with SQL server 2008 R2 using java. The same code is working with SQL server 2005.
I have tried to find out the port and ip for the sqlserver service and it is giving me
ip - 0.0.0.0 and port 1434
I tried to use the same connection string that works in SQL Server 2005, but it won't work for me in SQL Server 2008. Here is my connection string:
conn=DriverManager.getConnection(jdbc:sqlserver://127.0.0.1:1434:DatabaseNameconnect?autoReconnect=true,user, password);
This is the Error:
jdbc:sqlserver://127.0.0.1:1434;DatabaseName=connect;user=falcon;Password=admin
Could not connect to database
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.dnb.discovery.connection.ConnectionBean.makeMsSqlConnection(ConnectionBean.java:62)
at com.dnb.discovery.factory.MssqlDAOFactory.<init>(MssqlDAOFactory.java:18)
at com.dnb.discovery.dao.mssqldao.MssqlCompanyDAO.<init>(MssqlCompanyDAO.java:8)
at com.dnb.discovery.relevance.Relevance.modifyRelevanceIndex(Relevance.java:67)
at com.dnb.discovery.relevance.Relevance.calulateRelevanceScore(Relevance.java:36)
at com.dnb.discovery.dao.SolrDAO.readDataFromSolr(SolrDAO.java:222)
at com.dnb.discovery.searchservice.SearchService.buyerTextSearchAnonymous(SearchService.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.InvokerTube$2.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.sei.EndpointMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.sei.SEIInvokerTube.processRequest(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.AuthFilter.doFilter(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Any help ?
There are many possibilities for your problem:
Firewall
No TCP/IP connector
some services are not running
Try to connect with the SQL-management Studio to you database. If this works, try to connect with SQL-Authentification over TCP/IP.
update
Take a look at the Documentation at http://msdn.microsoft.com/en-en/library/ms143693(v=sql.90).aspx
One obvious problem is that SQL Server listens on port 1433, not 1434. I've already answered this question elsewhere, but I can't be sure if it's an exact match for your problem because you haven't told us what error message you get.