socket.io-client-java
socket.io-client-java copied to clipboard
android socketio aways disconnect transport error
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
the same problem(
same problem here ...
same problem here .... please help
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']
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...
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
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 .
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,还是没有用, 有人能帮助我吗
opts.transports = new String[]{WebSocket.NAME};我也加了这个设置,仍然无用
Opts. Transports = new String [] {WebSocket. NAME}; I also added this setup, which is still useless.
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.
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 longwriteTimeout
andreadTimeout
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'spingTimeout
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.