Open jmglov opened 9 years ago
I have an update on this issue. I made a minimal Unity project to reproduce this (zip file here), and I found that I can connect to the WebSocket.org echo server on ws://echo.websocket.org
.
However, I still cannot connect to my own server, which is based on the http-kit library for Clojure. I can connect to my server from the Unity editor, iOS, and every other websocket client I've tried, so there's something strange going on with the combination of websocket-sharp and http-kit, but only on Android. Ugh.
Can anyone suggest a good way to debug this? Can I turn on absurdly verbose logging in websocket-sharp? I suspect the issue is in the handshake process itself, as that is where I get the timeout.
Here's a minimal WebSocket server that demonstrates the issue: https://drive.google.com/file/d/0B6lDe0twne6NekxUVzVkdUxPaHc/view?usp=sharing
Run it with java -jar ws-server-test.jar
, and it will start listening for connections on ws://localhost:8080/
. Updating the test Unity project to connect to port 8080 of your machine's IP address, building for Android, and running on a device will reproduce the error.
I'm getting the same behaviour running against a node.js websocket server using "ws". Try connect to a SceneVR server to replicate. Did you make any discoveries?
Well that's super weird. I can connect to the production servers that run node servers using ws
behind nginx, but i cant connect directly to the node servers.
@bnolan Sorry, I should have followed up here.
I fixed the issue by upgrading to Unity 5, turning on full .NET API compatibility , and dropping the websocket-sharp code directly in my Assets
folder. Unity 4 could not build websocket-sharp like this, so I was using the DLL from the Asset Store.
websocket-sharp is working perfectly for me in the Unity editor and on iOS, but on Android,
Connect()
always times out before receiving a handshake. In the logs of my WebSockets server, I can see the Unity client connecting, and the handshake completes immediately from the server's point of view. On the Android side, however, my app hangs for awhile before finally reporting a timeout:I'm running Unity 4.6.3f1 Pro with both iOS and Android Pro, with a minimum Android API level of 4.0.3 and full .NET 2.0 compatibility level, using the websocket-sharp.dll from the Asset Store. I'm testing by exporting a development build as a Google Android Project and running it on my Android device with USB debugging from Android Studio.
Have you success reports from people using websocket-sharp on Android? I'm only using the client stuff, not the server.