I wrote simple server-client program to send information from client to server, but it doesn't work with the following errors:
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: transport error 202: connect failed: Permission denied
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
With the following exception too:
java.net.SocketException: Permission denied: 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 net.inthemoon.localhostconnectattempt.LocalhostConnectAttempt$2.run(LocalhostConnectAttempt.java:56)
at java.lang.Thread.run(Unknown Source)
The code is following:
package net.inthemoon.localhostconnectattempt;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
public class LocalhostConnectAttempt {
private static String hostName = "localhost";
private static int portNumber = 444;
public static void main(String[] args) throws InterruptedException {
Thread server = new Thread(new Runnable() {
@Override
public void run() {
try (
ServerSocket serverSocket = new ServerSocket(portNumber);
Socket clientSocket = serverSocket.accept();
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
) {
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println("Server: " + inputLine);
out.println("heard you");
if (inputLine.equals("bye")) {
System.out.println("Server: exiting");
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
});
server.setDaemon(true);
server.start();
Thread client = new Thread( new Runnable() {
@Override
public void run() {
try (
Socket kkSocket = new Socket(hostName, portNumber);
PrintWriter out = new PrintWriter(kkSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(
new InputStreamReader(kkSocket.getInputStream()));
) {
out.println("Hello world!");
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
Thread.sleep(5000);
client.start();
}
}
UPDATE
Disclosing localhost 127.0.0.1
in hosts
file didn't help.
UPDATE 2
I found the root of the problem: this was caused by [proxy autoconfiguration][1]. By some reason address of 127.0.0.1
was processing by proxy and was leading to the web page of proxy server. The addition of
function FindProxyForURL(url,host)
{
if( host == '127.0.0.1' ) {
return "DIRECT";
}
to wpad.dat
helped but I still don't understand an entire effect. I have proxy for a long time and it was no causing such an effect previously.
So I think this is also somehow related with IPv6
or something.