Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket 连接异常 #53

Open
q88qaz opened this issue Jan 14, 2022 · 6 comments
Open

WebSocket 连接异常 #53

q88qaz opened this issue Jan 14, 2022 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@q88qaz
Copy link

q88qaz commented Jan 14, 2022

E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.dppdkai.luckypandemo, PID: 10154
com.ejlchina.okhttps.internal.HttpException: WebSockt 连接异常: ws://myphp.com
at com.ejlchina.okhttps.internal.WebSocketTask$MessageListener.onFailure(WebSocketTask.java:278)
at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.java:570)
at okhttp3.internal.ws.RealWebSocket$1.onResponse(RealWebSocket.java:199)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:174)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
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:929)
Caused by: java.net.ProtocolException: Expected HTTP 101 response but was '200 OK'
at okhttp3.internal.ws.RealWebSocket.checkUpgradeSuccess(RealWebSocket.java:224)
at okhttp3.internal.ws.RealWebSocket$1.onResponse(RealWebSocket.java:195)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:174) 
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
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:929) 

@troyzhxu
Copy link
Owner

应该是连接地址不正确,正确的 websocket 连接地址在连接的时候会返回状态码 101,你这个地址它返回了 200

@troyzhxu troyzhxu added the help wanted Extra attention is needed label Jan 14, 2022
@q88qaz
Copy link
Author

q88qaz commented Jan 14, 2022

他是http协议的websocket

@q88qaz
Copy link
Author

q88qaz commented Jan 14, 2022

然后还带端口号

@q88qaz
Copy link
Author

q88qaz commented Jan 14, 2022

形如:
http://test.xxxxxxxxxx.com:2120

@troyzhxu
Copy link
Owner

那这确实不是 WebSocket 协议,可能是 SockJS 协议

@xyStephenZhou
Copy link

是安卓端吗??安卓端不支持socketjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants