I'm trying (unsuccessfully) to connect with a socket.io server, but I keep getting the same errors :
io.socket.SocketIOException: Error while handshaking
caused by java.net.ConnectException: failed to connect to my.domain.name.com (port 8080) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)
.
I just discovered that I'm supposed to send a cookie with the following values when handshaking : the domain, the path, the name and the value. After trying several potential ways to do it (based on this and this), I ended up with that piece of code, but it still not working :
String cookieString = "domain=" + "my.domain.name.com" + ";path=" + "/" + ";name=" + "auth" + ";value=" + "XXXXXtokenXXXXX";
CookieManager.getInstance().setCookie("http://my.domain.name.com:8080/", cookieString);
String header = CookieManager.getInstance().getCookie("my.domain.name.com:8080/");
final SocketIO socket = new SocketIO("my.domain.name.com:8080/");
socket.addHeader("Cookie", header);
socket.connect(new IOCallback()
{
...
}
CookieManager.getInstance().getCookie(...)
keeps returning null and the connection is still failing.
Could anybody help me add a cookie to the header please?
And for the record, I don't know what it could change, but I'm using this lib : https://github.com/Gottox/socket.io-java-client
Thanks in advance for your help !
Mathieu