Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.

Related tags

socket.io-client-java
Overview
Issues
  • Socket listeners not working but emit does.

    Socket listeners not working but emit does.

    The .on listener never seem to be fired! I've tried multiple versions of socket IO. This is a fantastic library Ive used on javascript. dont know why Java seem to have a problem :( Ive tried extending the Service class. Weird thing is my emits work properly but my .on listeners don't seem to fire at all! Here is the code :

    import io.socket.client.IO;
    import io.socket.client.Socket;
    import io.socket.emitter.Emitter;
    
    public class SocketService extends Service {
        final String TAG="SocketService";
        JSONObject user_data;
        private Socket socket;
    
        private final IBinder mBinder = new MyBinder();
        public class MyBinder extends Binder {
            SocketService getService() {
                return SocketService.this;
            }
        }
    
        @Override
        public void onCreate(){
            super.onCreate();
            try {
                socket = IO.socket("http://serverIP:port/"); //this gets connected
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
            Log.d(TAG, "onCreate");
            socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
    
                @Override
                public void call(Object... args) {
                    Log.d(getClass().getCanonicalName(), "Connected to server");
                }
    
            }).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
    
                @Override
                public void call(Object... arg0) {
                    Log.d(getClass().getCanonicalName(), "Disconnected from server");
                }
    
            });
            socket.on("friendcall", new Emitter.Listener() {
                @Override
                public void call(Object... args) {
                    JSONObject data = (JSONObject) args[0];
                    Log.d(TAG, "Handling friendcall");
                    try {
                        String callFrom = data.getString("from");
                        Log.d(TAG, "Call from : " + callFrom);
                    } catch (JSONException e) {
                        Log.d(TAG, "friend call object cannot be parsed");
                    }
    
                }
            });
    
            Log.d(TAG, "onStartCommand. Socket should be up");
            socket.connect();
        }
    
        @Override
        public int onStartCommand(Intent intent, int flags, int startId) {
    
            Bundle extras = intent.getExtras();
            if(extras!=null){
                try {
                    user_data = new JSONObject(extras.getString("USER_DATA"));
                    socket.emit("giveMeID", user_data.getString("email"));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
    
            return Service.START_NOT_STICKY;
        }
    
    
        @Override
        public IBinder onBind(Intent intent) {
            //TODO for communication return IBinder implementation
            return null;
        }
    
        @Override
        public void onDestroy(){
            socket.disconnect();
            super.onDestroy();
            Log.d(TAG,"onDestroy");
        }
    
    }
    

    lib version tried ,

    compile ('io.socket:socket.io-client:0.6.3') {
            // excluding org.json which is provided by Android
            exclude group: 'org.json', module: 'json'
        }
    

    Also tried the com.github.nkzawa:socket.io-client:0.3.0 package

    opened by kevz93 56
  • Consistent

    Consistent "xhr poll error" is caused by hanging instances of XHRPolling

    #241 may be related

    A consistent "xhr poll error" seems to be caused by hanging connections. The condition is typically caused when manager calls onclose() and interrupts a pending xhr request.

    The error does typically never occur as long as xhr requests are serviced by the server, e.g. a packet is returned while the request is pending. The client then receives the packet and posts a new request.

    Timeouts play a significant role. The client can only recover from the condition, if the maximum timeout imposed by reconnectionDelayMax is large enough to ensure the previous request has been cancelled. If it is still pending, then the new request will immediately fail as well, get stuck, and block the next poll request.

    This is the reason why it sometimes takes extremely long, until a client recovers from disconnects. When connection is retried, the backoff timeout is reset to reconnectionDelay, then increased. Reconnect attempts fail for a long time, until the gap is large enough.

    This issue may exclusively happen or happen worse on Android 4.2 (SKD 17) [probably 4.1-4.3]. As it seems, there is an underlying network problem when handling long-running requests (see #248). I could not see any relationships between size of connection pool and such, but I could see that sometimes multiple requests have been pending in parallel. It looks like it works fine as long as there is a single pending request, but it fails (always or often) if 2 or more long running requests are pending.

    I tried using okhttp-urlconnection instead of Android's HttpUrlConnection, but this did not make it any better. The issue is just better debuggable, but it remains. Another indicator that we probably have a networking issue here.

    How to reproduce:

    • set upgrade = false, so we only have xhr polling

    • open a socket

    • provoke a network outage

    • hope the client goes into the "xhr poll error" loop

    • watch how it does not recover

    • in Manager, set a breakpoint AFTER this line:

      `this.reconnecting = true; // ln 501`
      
    • wait long enough to ensure all pending xhr connections have been timed out

    • keep running the code

    • watch how the client reconnects and recovers

    opened by oliverhausler 42
  • OkHttp connections do not seem to be closed

    OkHttp connections do not seem to be closed

    My application show the follow log:

    01-26 14:32:47.975 14396-16699/com.closic W/OkHttpClient: A connection to https://localhost:3101/ was leaked. Did you forget to close a response body?
    

    3101 is the Socket.io port. Can you check if all connections are closed?

    opened by sandrocsimas 34
  • disconnecting unexpectedly

    disconnecting unexpectedly

    After a period the application disconnecting from the server, and i can't produce a pattern for this disconnection. i am implementing chat application due to this disconnection i find the users disconnected unexpectedly. so what i should i do to solve this case ?

    Another issue. when i send message i can't know if it arrived to the other side or not ? is there a callback functions in the emit request guide me if it failed to reach or not ?

    duplicate 
    opened by MohamedHatemAbdu 32
  • java.net.MalformedURLException: Unknown protocol: ws

    java.net.MalformedURLException: Unknown protocol: ws

    Hi. i try to connect to socket server which start with "ws://..." and when I set this url to

     IO.socket(pathSocket, options);
    

    I receive error

     java.lang.RuntimeException: java.net.MalformedURLException: Unknown protocol: ws
     W/System.err﹕ at io.socket.client.Url.parse(Url.java:52)
     W/System.err﹕ at io.socket.client.IO.socket(IO.java:60)
     W/System.err﹕ at io.socket.client.IO.socket(IO.java:41)
    
    bug 
    opened by Zo2m4bie 32
  • How to implement socket.io 1.0 in android

    How to implement socket.io 1.0 in android

    I need socket io 1.0.x client in android. but here i can see only java implementation, please any one help me.

    opened by prabhu-syn 31
  • Unable to connect using https

    Unable to connect using https

    /I am using node.js server side and android and another node.js client side web application. The wep application is able to connect securely while the android application is just giving an timeout error./

    //The code for creating sslcontext Log.d(TAG,"setupContext"); //Using a client certificate String password = "password" KeyStore keyStore = KeyStore.getInstance("PKCS12"); InputStream is = context.getResources().openRawResource(R.raw.client_crt); keyStore.load(is, password.toCharArray()); is.close();

        KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");
        kmf.init(keyStore, password.toCharArray());
        KeyManager[] keyManagers = kmf.getKeyManagers();
    
        // Load CAs from an InputStream
        // (could be from a resource or ByteArrayInputStream or ...)
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        // Using self signed certificate
        is = context.getResources().openRawResource(R.raw.cacert);
        InputStream caInput = new BufferedInputStream(is);
        Certificate ca;
        ca = cf.generateCertificate(caInput);
        Log.i(TAG,"ca=" + ((X509Certificate) ca).getSubjectDN());
        caInput.close();
    
    
        // Create a KeyStore containing our trusted CAs
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null);
        trustStore.setCertificateEntry("ca", ca);
    
        // Create a TrustManager that trusts the CAs in our KeyStore
        TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
        tmf.init(trustStore);
        TrustManager[] trustManagers =  tmf.getTrustManagers();
    
        // Create an SSLContext that uses our TrustManager
        SSLContext sslcontext = SSLContext.getInstance("TLS");
    
        sslcontext.init(keyManagers, trustManagers, null);
    
        IO.Options opts = new IO.Options();
        opts.forceNew = true;
        opts.reconnection = false;
        opts.sslContext = mSslContext;
        opts.secure=true;
        mSocket = IO.socket("https://" + mIpAddress + ":" + mPort+"/", opts);
        mSocket.connect();
        mSocket.on(Socket.EVENT_CONNECT, mConnectionListener);
        mSocket.on(Socket.EVENT_DISCONNECT,mDisconnectionListener);
        mSocket.on(Socket.EVENT_ERROR,mErrorListener);
        mSocket.on(Socket.EVENT_MESSAGE,mMessageListener);
        mSocket.on(Socket.EVENT_CONNECT_ERROR,mConnectionErrorListener);
    
         // I never get call for EVENT_CONNECT
    

    ///////////////////////////SERVER CODE/////////////////////////////////////////////// var privateKey = fs.readFileSync('certificates/server.key').toString(); var certificate = fs.readFileSync('certificates/server.crt').toString(); var ca = fs.readFileSync('certificates/cacert.pem').toString(); // Sending and receiving events with Socket.IO var app = express(); https.globalAgent.options.rejectUnauthorized = false; var server = https.createServer({key:privateKey,cert:certificate,ca:ca },app); // var server = require('http').Server(app); exports.io = require('./sockets').listen(server); //Server is listening on port 3000

    Please tell a way to enable logs in android app for socket.io and possible cause of this problem. There is no activity in node.js terminal as if the socket never got a call after using https it work fine if I use http Thanks and regards, Anshul

    opened by anshulvij 27
  • Websocket Upgrade https

    Websocket Upgrade https

    I've been having an issue with this library and https for quite a while now. When attempting to connect to my node.js server over https the connection never upgrades to a Websocket and permanent uses xhr polling. This is with both https termination on HAPROXY and a direct connection to a node server running the https itself. As soon as I remove https and connect via https the connection instantly upgrades to a Web socket. Having had a look at the logs the client probes correctly and creates a Web socket Transport. This transport immediately errors and the client falls back to xhr polling. The only success I had was giving IO an sslcontext which accepted all certs and host names (My Certificate is a valid one and trusted by Android by defualt) and setting the only transport to Web socket. Now the first time this is run it gets into a infinite Web socket loop and starts leaking memory. However on later attempts having been restarted the client does sometimes connect correctly via a Web socket. Having looked at the Engine.io source the Web socket is failing the ping/pong probe when using https. I've personally exhausted all things I can think of and any help would be much appreciated - I can provide any logs if you need them. It just seems odd that it upgrades perfectly on http and adding ssl breaks it immediatlty

    opened by KieranWebber 27
  • Socket.IO-client.java disconnect and reconnect repeatedly

    Socket.IO-client.java disconnect and reconnect repeatedly

    I am using socket.io 1.2.1 on my node server and the android socket connects with the server fine but after some minutes it automatically disconnect and reconnect repeatedly. Whats wrong with my code? i am using socket.io-client-0.1.1.jar, engine.io-client-0.2.1.jar and Java-WebSocket-1.3.0.jar libraries. here is the java code

        private void socketTest() throws URISyntaxException{
        socket = IO.socket("http://192.168.169.2:8082");
        socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
    
          @Override
          public void call(Object... args) {
            socket.emit("test", "awesome");
    
          }
    
        }).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
    
          @Override
          public void call(Object... args) {}
    
        });
        socket.connect();
    
       }
    

    and here is the server side code

      io.on('connection', function (socket) {
        console.log('a user connected');
        socket.on('disconnect', function () {
           console.log('user disconnected');
        });
        socket.on('test',function(msg){
           console.log("This is "+msg);
        });
       });
    

    and the logs screenshot on the server

    stack

    Question link on stackoverflow

    bug 
    opened by miqe 27
  • Unable to create a connection

    Unable to create a connection

    Hi, I am trying to connect to my socket server using socket-io library. But I am getting SocketIOException. Please suggest the reason. I am using the below jar files downloaded from "http://mvnrepository.com/artifact/com.github.nkzawa/socket.io-client" engine.io-client-0.3.1.jar socket.io-client-0.3.0.jar Java-WebSocket-1.3.0.jar

    On the other hand, everything is working fine in phonegap app for ios using nodeJs. But I am unable to connect in android native app. I also tried with this library "https://github.com/Gottox/socket.io-java-client". but no success. Please suggest the way so that I can implement this.

    opened by Ahmad19860 24
  • How to customize the default URL(/socket.io/?EIO=...) in client and server?

    How to customize the default URL(/socket.io/?EIO=...) in client and server?

    I want to customize the default URL such as /MySocket/?EIO=...

    question 
    opened by Tracy0725 1
  • Is it possible to connect to a server that does not have the websocket transport?

    Is it possible to connect to a server that does not have the websocket transport?

    Hello, I have a Socket.io server that works very well, I can connect with different libraries (python, js etc ...). But with this library I can't connect. The special thing about my server is that it does not implement the WebSocket transport.

    I can connect and exchange messages for about 5 seconds, then I am disconnected.

    Here is the error I am getting:

    io.socket.engineio.client.EngineIOException: xhr poll error
            at io.socket.engineio.client.Transport.onError(Transport.java:65)
            at io.socket.engineio.client.transports.PollingXHR.access$100(PollingXHR.java:26)
            at io.socket.engineio.client.transports.PollingXHR$6$1.run(PollingXHR.java:129)
            at io.socket.thread.EventThread$2.run(EventThread.java:80)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
            at java.lang.Thread.run(Thread.java:761)
         Caused by: java.net.SocketTimeoutException: timeout
            at okio.Okio$4.newTimeoutException(Okio.java:232)
            at okio.AsyncTimeout.exit(AsyncTimeout.java:285)
            at okio.AsyncTimeout$2.read(AsyncTimeout.java:241)
            at okio.RealBufferedSource.indexOf(RealBufferedSource.java:354)
            at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:226)
            at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215)
            at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
            at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
            at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
            at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
            at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
            at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:127)
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
            at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:257)
            at okhttp3.RealCall$AsyncCall.execute(RealCall.java:201)
            at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
            at java.lang.Thread.run(Thread.java:761) 
         Caused by: java.net.SocketException: Socket operation on non-socket
            at java.net.SocketInputStream.socketRead0(Native Method)
            at java.net.SocketInputStream.read(SocketInputStream.java:151)
            at java.net.SocketInputStream.read(SocketInputStream.java:120)
            at okio.Okio$2.read(Okio.java:140)
            at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
            at okio.RealBufferedSource.indexOf(RealBufferedSource.java:354) 
            at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:226) 
            at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215) 
            at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189) 
            at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:127) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:257) 
            at okhttp3.RealCall$AsyncCall.execute(RealCall.java:201) 
            at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
            at java.lang.Thread.run(Thread.java:761) 
    

    The last part of the stack trace is not always the same, sometimes I have:

    Caused by: java.net.SocketException: Socket closed
            at java.net.SocketInputStream.socketRead0(Native Method)
            at java.net.SocketInputStream.read(SocketInputStream.java:151)
            at java.net.SocketInputStream.read(SocketInputStream.java:120)
            at okio.Okio$2.read(Okio.java:140)
            at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
            at okio.RealBufferedSource.indexOf(RealBufferedSource.java:354) 
            at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:226) 
            at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215) 
            at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189) 
            at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:127) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:257) 
            at okhttp3.RealCall$AsyncCall.execute(RealCall.java:201) 
            at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
            at java.lang.Thread.run(Thread.java:761) 
    

    or

    Caused by: java.net.SocketTimeoutException: Software caused connection abort
            at java.net.SocketInputStream.socketRead0(Native Method)
            at java.net.SocketInputStream.read(SocketInputStream.java:151)
            at java.net.SocketInputStream.read(SocketInputStream.java:120)
            at okio.Okio$2.read(Okio.java:140)
            at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
            at okio.RealBufferedSource.indexOf(RealBufferedSource.java:354) 
            at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:226) 
            at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215) 
            at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189) 
            at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:127) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
            at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
            at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:257) 
            at okhttp3.RealCall$AsyncCall.execute(RealCall.java:201) 
            at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
            at java.lang.Thread.run(Thread.java:761) 
    
    bug 
    opened by MathiasDrapier 1
  • Can I set Socket.id during connection If i remember previous socket id returned by server?

    Can I set Socket.id during connection If i remember previous socket id returned by server?

    I connected from android client using socket.connect() it returned me socket.id "Zhy3pyqFrJrAJtjUAAAT"

    When app is killed and opened again, can i set this ID in socket.id and start using it? (Because I set the server to preserve this connection for sometime)

    question 
    opened by hi2rashid 0
  • use EVENT_CONNECTING in v2

    use EVENT_CONNECTING in v2

    hi how can i use EVENT_CONNECTING in version 2.0.0 ? i Migrating from 1.0.0 to 2.0.0

    opened by drsoosmar 0
  • How to use a socket offline?

    How to use a socket offline?

    Describe what you would like to know or do I am working on an IoT project where two devices communicate; a phone and a camera.

    1. The camera opens a hotspot.
    2. The phone connects to a hotspot
    3. And now I need communication between devices using socket.

    How can I use a socket over a hotspot without access to the internet?

    question 
    opened by denebchorny 0
  • java.net.MalformedURLException: unknown protocol: wss

    java.net.MalformedURLException: unknown protocol: wss

    According to the documentation, there is no problem in using the WSS protocol

    Socket socket = IO.socket("wss://example.com"); // OK, similar to the example above

    But when I use it, it gives the following error: java.lang.RuntimeException: java.net.MalformedURLException: unknown protocol: wss

    Socket mSocket = IO.socket("wss://mydomain.com");

    please help me

    question 
    opened by aminrz3 1
  • Document version 1.x.x

    Document version 1.x.x

    Hello all, I want to use the version 1.0.0. And I also know that there were many changes in version 2.0.1. But I can't see any document version 1.0.0 in git. How can I get it ?

    question 
    opened by greeneley 0
  • Always Crash on Connect

    Always Crash on Connect

    I struggled with this error report and get nothing wrong in my code. I implement my socket client in my fragment. I use version 1.0.1 of this library and use version 2.3.0 at my Node.js server.

    2020-12-11 17:12:14.567 21432-21557/com.example.myapp E/EventThread: Task threw exception
        java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
            at io.socket.client.Socket.onevent(Socket.java:337)
            at io.socket.client.Socket.onpacket(Socket.java:289)
            at io.socket.client.Socket.access$100(Socket.java:24)
            at io.socket.client.Socket$2$2.call(Socket.java:120)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.client.Manager.ondecoded(Manager.java:431)
            at io.socket.client.Manager.access$1600(Manager.java:30)
            at io.socket.client.Manager$7.call(Manager.java:407)
            at io.socket.parser.IOParser$Decoder.add(IOParser.java:105)
            at io.socket.client.Manager.ondata(Manager.java:423)
            at io.socket.client.Manager.access$1000(Manager.java:30)
            at io.socket.client.Manager$2.call(Manager.java:374)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.engineio.client.Socket.onPacket(Socket.java:551)
            at io.socket.engineio.client.Socket.access$1000(Socket.java:36)
            at io.socket.engineio.client.Socket$5.call(Socket.java:335)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.engineio.client.Transport.onPacket(Transport.java:126)
            at io.socket.engineio.client.Transport.onData(Transport.java:118)
            at io.socket.engineio.client.transports.WebSocket.access$100(WebSocket.java:24)
            at io.socket.engineio.client.transports.WebSocket$1$2.run(WebSocket.java:71)
            at io.socket.thread.EventThread$2.run(EventThread.java:80)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
            at java.lang.Thread.run(Thread.java:764)
    2020-12-11 17:12:14.570 21432-21557/com.example.myapp E/AndroidRuntime: FATAL EXCEPTION: EventThread
        Process: com.example.myapp, PID: 21432
        java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
            at io.socket.client.Socket.onevent(Socket.java:337)
            at io.socket.client.Socket.onpacket(Socket.java:289)
            at io.socket.client.Socket.access$100(Socket.java:24)
            at io.socket.client.Socket$2$2.call(Socket.java:120)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.client.Manager.ondecoded(Manager.java:431)
            at io.socket.client.Manager.access$1600(Manager.java:30)
            at io.socket.client.Manager$7.call(Manager.java:407)
            at io.socket.parser.IOParser$Decoder.add(IOParser.java:105)
            at io.socket.client.Manager.ondata(Manager.java:423)
            at io.socket.client.Manager.access$1000(Manager.java:30)
            at io.socket.client.Manager$2.call(Manager.java:374)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.engineio.client.Socket.onPacket(Socket.java:551)
            at io.socket.engineio.client.Socket.access$1000(Socket.java:36)
            at io.socket.engineio.client.Socket$5.call(Socket.java:335)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.engineio.client.Transport.onPacket(Transport.java:126)
            at io.socket.engineio.client.Transport.onData(Transport.java:118)
            at io.socket.engineio.client.transports.WebSocket.access$100(WebSocket.java:24)
            at io.socket.engineio.client.transports.WebSocket$1$2.run(WebSocket.java:71)
            at io.socket.thread.EventThread$2.run(EventThread.java:80)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
            at java.lang.Thread.run(Thread.java:764)
    2020-12-11 17:12:14.578 21432-21558/com.example.myapp E/EventThread: Task threw exception
        java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
            at io.socket.client.Socket.onevent(Socket.java:337)
            at io.socket.client.Socket.onpacket(Socket.java:289)
            at io.socket.client.Socket.access$100(Socket.java:24)
            at io.socket.client.Socket$2$2.call(Socket.java:120)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.client.Manager.ondecoded(Manager.java:431)
            at io.socket.client.Manager.access$1600(Manager.java:30)
            at io.socket.client.Manager$7.call(Manager.java:407)
            at io.socket.parser.IOParser$Decoder.add(IOParser.java:105)
            at io.socket.client.Manager.ondata(Manager.java:423)
            at io.socket.client.Manager.access$1000(Manager.java:30)
            at io.socket.client.Manager$2.call(Manager.java:374)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.engineio.client.Socket.onPacket(Socket.java:551)
            at io.socket.engineio.client.Socket.access$1000(Socket.java:36)
            at io.socket.engineio.client.Socket$5.call(Socket.java:335)
            at io.socket.emitter.Emitter.emit(Emitter.java:117)
            at io.socket.engineio.client.Transport.onPacket(Transport.java:126)
            at io.socket.engineio.client.Transport.onData(Transport.java:118)
            at io.socket.engineio.client.transports.WebSocket.access$100(WebSocket.java:24)
            at io.socket.engineio.client.transports.WebSocket$1$2.run(WebSocket.java:71)
            at io.socket.thread.EventThread$2.run(EventThread.java:80)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
            at java.lang.Thread.run(Thread.java:764)
    
    bug 
    opened by faizalmp 4
  • This framework is not designed for multi-thread java application?

    This framework is not designed for multi-thread java application?

    As I see the thread model is base on EventThread.java, which is included in engine-io.

    enhancement 
    opened by zhongqiu-jiang 2
  • Connection not established

    Connection not established

    I have read the ReadMe file and according to that used library version 0.9.0

    • I have resolved the transport error using the following code
    val opts = IO.Options()
    opts.transports = arrayOf(WebSocket.NAME)
    mSocket = IO.socket("Domain URL", opts)!!
    

    I have also added Trust Manager to okhttpclient using the following code using this

    val trustManagerFactory: TrustManagerFactory = TrustManagerFactory.getInstance(
                    TrustManagerFactory.getDefaultAlgorithm()
                )
    trustManagerFactory.init(null as KeyStore?)
    val trustManagers: Array<TrustManager> = trustManagerFactory.trustManagers
    val trustManager = trustManagers[0] as X509TrustManager
    
    
    val sslContext = SSLContext.getInstance("TLS")
    sslContext.init(null, arrayOf<TrustManager>(trustManager), null)
    val sslSocketFactory = sslContext.socketFactory
    
    val okHttpClient = OkHttpClient.Builder()
                    .hostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())
                    .sslSocketFactory(
                        sslSocketFactory,
                        trustManager
                    )
                    .connectTimeout(20, TimeUnit.SECONDS)
                    .writeTimeout(1, TimeUnit.MINUTES)
                    .readTimeout(1, TimeUnit.MINUTES)
                    .build()
    IO.setDefaultOkHttpCallFactory(okHttpClient)
    IO.setDefaultOkHttpWebSocketFactory(okHttpClient)
    
    • Now facing the following error
    io.socket.engineio.client.EngineIOException: websocket error
    

    How to overcome this issue any idea?

    opened by ntpanchal 1
Releases(socket.io-client-2.0.1)
  • socket.io-client-2.0.1(Apr 26, 2021)

    Bug Fixes

    • fix usage with ws:// scheme (67fd5f3)
    • ensure buffered events are sent in order (4885e7d)
    • ensure the payload format is valid (e8ffe9d)
    • emit a CONNECT_ERROR event upon connection failure (d324e7f)

    Diff: https://github.com/socketio/socket.io-client-java/compare/socket.io-client-2.0.0...socket.io-client-2.0.1

    Source code(tar.gz)
    Source code(zip)
  • socket.io-client-2.0.0(Dec 15, 2020)

    This release is compatible with Socket.IO v3: https://socket.io/blog/socket-io-3-release/

    Migration guide: http://socketio.github.io/socket.io-client-java/migrating_from_1_x.html

    Features

    Diff: https://github.com/socketio/socket.io-client-java/compare/socket.io-client-1.0.1...socket.io-client-2.0.0

    Source code(tar.gz)
    Source code(zip)
  • socket.io-client-1.0.1(Dec 15, 2020)

    Bug Fixes

    • don't process socket.connect() if we are already re-connecting (#577) (54b7311)
    • handle case where URI.getHost() returns null (#484) (567372e)

    Diff: https://github.com/socketio/socket.io-client-java/compare/socket.io-client-1.0.0...socket.io-client-1.0.1

    Source code(tar.gz)
    Source code(zip)
Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.

Socket.IO-client Java This is the Socket.IO Client Library for Java, which is simply ported from the JavaScript client. See also: Android chat demo en

Socket.IO 4.6k Mar 13, 2021
A Java library that implements a ByteChannel interface over SSLEngine, enabling easy-to-use (socket-like) TLS for Java applications.

TLS Channel TLS Channel is a library that implements a ByteChannel interface over a TLS (Transport Layer Security) connection. It delegates all crypto

Mariano Barrios 113 Mar 1, 2021
Socket.IO server implemented on Java. Realtime java framework

Netty-socketio Overview This project is an open-source Java implementation of Socket.IO server. Based on Netty server framework. Checkout Demo project

Nikita Koksharov 5.2k Mar 14, 2021
A High Performance Network ( TCP/IP ) Library

Chronicle-Network About A High Performance Network library Purpose This library is designed to be lower latency and support higher throughputs by empl

Chronicle Software : Open Source 160 Mar 8, 2021
TCP/UDP client/server library for Java, based on Kryo

KryoNet can be downloaded on the releases page. Please use the KryoNet discussion group for support. Overview KryoNet is a Java library that provides

Esoteric Software 1.6k Mar 12, 2021
Asynchronous Http and WebSocket Client library for Java

Async Http Client Follow @AsyncHttpClient on Twitter. The AsyncHttpClient (AHC) library allows Java applications to easily execute HTTP requests and a

AsyncHttpClient 5.7k Apr 23, 2021
ssh, scp and sftp for java

sshj - SSHv2 library for Java To get started, have a look at one of the examples. Hopefully you will find the API pleasant to work with :) Getting SSH

Jeroen van Erp 1.8k Mar 12, 2021
Efficient reliable UDP unicast, UDP multicast, and IPC message transport

Aeron Efficient reliable UDP unicast, UDP multicast, and IPC message transport. Java and C++ clients are available in this repository, and a .NET clie

Real Logic 5.4k Mar 12, 2021
Square’s meticulous HTTP client for the JVM, Android, and GraalVM.

OkHttp See the project website for documentation and APIs. HTTP is the way modern applications network. It’s how we exchange data & media. Doing HTTP

Square 39.6k Mar 13, 2021
Pcap editing and replay tools for *NIX and Windows - Users please download source from

Tcpreplay Tcpreplay is a suite of GPLv3 licensed utilities for UNIX (and Win32 under Cygwin) operating systems for editing and replaying network traff

AppNeta, Inc. 745 Mar 10, 2021
An annotation-based Java library for creating Thrift serializable types and services.

Drift Drift is an easy-to-use, annotation-based Java library for creating Thrift clients and serializable types. The client library is similar to JAX-

null 177 Mar 3, 2021
A Java library for capturing, crafting, and sending packets.

Japanese Logos Pcap4J Pcap4J is a Java library for capturing, crafting and sending packets. Pcap4J wraps a native packet capture library (libpcap, Win

Kaito Yamada 854 Mar 13, 2021
Java API over Accelio

JXIO JXIO is Java API over AccelIO (C library). AccelIO (http://www.accelio.org/) is a high-performance asynchronous reliable messaging and RPC librar

Accelio 71 Jan 5, 2021
Fibers and actors for web development

COMSAT Scalable, Concurrent Web Apps Getting started Add the following Maven/Gradle dependencies: Feature Artifact Servlet integration for defining fi

Parallel Universe 586 Feb 23, 2021