socket.io-client-java icon indicating copy to clipboard operation
socket.io-client-java copied to clipboard

android socketio aways disconnect transport error

Open 164966580 opened this issue 6 years ago • 11 comments

Hello. Please help me. Android Socketio "io.socket:socket.io-client:0.9.0". Server: netty-socketio/1.7.7 aways from onConnect is ok to diconnected transport error。May not upgrade to websocket。Anybody encountered the same problem?Pelase help。Thank U

164966580 avatar Jan 19 '18 04:01 164966580

the same problem(

Bendor avatar Jan 23 '18 01:01 Bendor

same problem here ...

AhmedX6 avatar Feb 04 '18 16:02 AhmedX6

same problem here .... please help

s9443112 avatar Feb 13 '18 11:02 s9443112

Set the transports explicitly to websockets when connecting from the client. As in: io(YOUR_SERVER_URL_HERE,{ transports: ['websocket'] })

The default is ['polling', 'websocket']

TonyT9 avatar Apr 02 '18 16:04 TonyT9

I configured my code like this, IO.Options options = new IO.Options(); options.transports = new String[]{WebSocket.NAME}; options.query = "token=my custom token"; Socket mSocket = IO.socket("https://mydomain.com/", options);

Fixed my problem...

khaleeljageer avatar Apr 09 '18 09:04 khaleeljageer

Sorry, late reply. I solved the problem because I used Charles, which caused the problem. When I turned off the Charles agent, the problem no longer appeared. I don't know exactly why, but the problem is solved.Thanks for your reply

164966580 avatar Apr 09 '18 10:04 164966580

Ok~

Json Snow [email protected]於 2018年4月9日 週一,下午6:07寫道:

Sorry, late reply. I solved the problem because I used Charles, which caused the problem. When I turned off the Charles agent, the problem no longer appeared. I don't know exactly why, but the problem is solved.Thanks for your reply

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/socketio/socket.io-client-java/issues/491#issuecomment-379701932, or mute the thread https://github.com/notifications/unsubscribe-auth/AOeJ_0b_lqx_sEiGWMUNRmwAEpeOzlfBks5tmzLWgaJpZM4Rj-eu .

s9443112 avatar Apr 09 '18 10:04 s9443112

I also encountered ["transport error"] in onDisConnect, the client accidentally disconnect after a period of time, the client version was 1.0.0, and then it was changed to 0.8.3, still no use, can someone help me?

我也遇到["transport error"] 在onDisConnect,客户端在使用一段时间后,偶然 disconnect 了,客户端版本是1.0.0,后来改为0.8.3,还是没有用, 有人能帮助我吗

chenguozhi avatar Apr 23 '18 08:04 chenguozhi

  opts.transports = new String[]{WebSocket.NAME};我也加了这个设置,仍然无用

Opts. Transports = new String [] {WebSocket. NAME}; I also added this setup, which is still useless.

chenguozhi avatar Apr 23 '18 08:04 chenguozhi

Dear all, It seems like the problem would probably be the configuration of okHttp.

           OkHttpClient okHttpClient = new OkHttpClient.Builder()
                    .hostnameVerifier(hostnameVerifier)
                    .sslSocketFactory((SSLSocketFactory) SSLSocketFactory.getDefault(), trustManager)
                    .connectTimeout(20, TimeUnit.SECONDS)
                    .writeTimeout(1, TimeUnit.MINUTES)
                    .readTimeout(1, TimeUnit.MINUTES)
                    .build();
            IO.setDefaultOkHttpCallFactory(okHttpClient);
            IO.setDefaultOkHttpWebSocketFactory(okHttpClient);

By adding connectTimeout, and providing it a long writeTimeout and readTimeout seems to work for me. Note: There is a heartbeat mechanism that you can specify on Socket.IO Server, which I think the value here should tally with your server's pingTimeout value. Note2: The default values of these parameters in okHttp is 10000ms or 10 seconds.

LeeBoonKong avatar Nov 09 '18 03:11 LeeBoonKong

Dear all, It seems like the problem would probably be the configuration of okHttp.

           OkHttpClient okHttpClient = new OkHttpClient.Builder()
                    .hostnameVerifier(hostnameVerifier)
                    .sslSocketFactory((SSLSocketFactory) SSLSocketFactory.getDefault(), trustManager)
                    .connectTimeout(20, TimeUnit.SECONDS)
                    .writeTimeout(1, TimeUnit.MINUTES)
                    .readTimeout(1, TimeUnit.MINUTES)
                    .build();
            IO.setDefaultOkHttpCallFactory(okHttpClient);
            IO.setDefaultOkHttpWebSocketFactory(okHttpClient);

By adding connectTimeout, and providing it a long writeTimeout and readTimeout seems to work for me. Note: There is a heartbeat mechanism that you can specify on Socket.IO Server, which I think the value here should tally with your server's pingTimeout value. Note2: The default values of these parameters in okHttp is 10000ms or 10 seconds.

This really worked for me.. Adding timeout using OKHTTP3, that stabilised connection. Didn't get timeout for 15 20 minutes. I didn't use HostNameVerifier and SSLSocketFactory though.

rohankandwal avatar Nov 17 '18 14:11 rohankandwal