-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Support WebSocket sub-protocols on Android #5810
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
Comments
Hey mikemintz, thanks for reporting this issue! React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
|
+1: I am using STOMP.js over WS and it is working in iOS but not in Android. Most likely the same issue. |
the WebSocketModule.java line 66 says:
related code in okhttp: WebSocketCall.java line 71. I tried to hard-coded in WebSocketModule.java line 87 with I tested it on [email protected] Does that mean we can add back the support of websocket sub protocols now? |
Summary:Hey there and thanks for submitting a pull request! Please have a look at the following checklist so that others have enough information to review your pull request: **motivation** WebSocket spec supports [Sec-WebSocket-Protocol](https://tools.ietf.org/html/rfc6455#section-11.3.4) as a standard way for negotiate a sub protocol between client and server. * ios WebSocket implementation supports it. * android WebSocket implementation ignores this header, leave a comment syas: "OkHttp will overrides it", so it did not implement. * after some test, OkHttp doesn't override the header we add. **Test plan (required)** 1. run and react-native app on android 2. at the main page, invoke: `var ws = new WebSocket('ws://example.ws-service.fakedomain.com', 'my-sub-protocol');` 3. see the header if it send the correct header, ex, use ngrep: `sudo ngrep -t -Wbyline -deth0 host example.ws-service.fakedomain.com and port 80` you should see the WebSocket initial GET handshake includes header: `Sec-WebSocke Closes facebook#6223 Differential Revision: D3162822 fb-gh-sync-id: a00f1c0f3e1c24ad6aa234329cbb2abad7664264 fbshipit-source-id: a00f1c0f3e1c24ad6aa234329cbb2abad7664264
Summary:Hey there and thanks for submitting a pull request! Please have a look at the following checklist so that others have enough information to review your pull request: **motivation** WebSocket spec supports [Sec-WebSocket-Protocol](https://tools.ietf.org/html/rfc6455#section-11.3.4) as a standard way for negotiate a sub protocol between client and server. * ios WebSocket implementation supports it. * android WebSocket implementation ignores this header, leave a comment syas: "OkHttp will overrides it", so it did not implement. * after some test, OkHttp doesn't override the header we add. **Test plan (required)** 1. run and react-native app on android 2. at the main page, invoke: `var ws = new WebSocket('ws://example.ws-service.fakedomain.com', 'my-sub-protocol');` 3. see the header if it send the correct header, ex, use ngrep: `sudo ngrep -t -Wbyline -deth0 host example.ws-service.fakedomain.com and port 80` you should see the WebSocket initial GET handshake includes header: `Sec-WebSocke Closes facebook#6223 Differential Revision: D3162822 fb-gh-sync-id: a00f1c0f3e1c24ad6aa234329cbb2abad7664264 fbshipit-source-id: a00f1c0f3e1c24ad6aa234329cbb2abad7664264
I rely on the
protocols
argument in the WebSocket constructor to negotiate the client/server protocol. It looks like it's supported in react-native iOS, but Android appears to be ignoring it.See WebSocketModule.java line 66
The text was updated successfully, but these errors were encountered: