action-cable-react icon indicating copy to clipboard operation
action-cable-react copied to clipboard

WebSocket in Android doesn't work

Open haozeng opened this issue 8 years ago • 2 comments

Description

We have React-Native app built for both IOS and Android. The websocket works well with IOS. But when we are testing in android, it always says failed to upgrade to WebSocket.

Here are some logs we read both from backend server for IOS and Android. Not able to capture any useful logs when websocket connection is built from the mobile side.

The backend is rails 5 with action cable and on mobile side, we are using a library that uses actioncable API (https://github.com/schneidmaster/action-cable-react)

Any feedback is greatly appreciated.

2017-06-21T23:05:05.850190+00:00 heroku[router]: at=info method=GET path="/cable" host=anyperk-wellness.herokuapp.com request_id=911403d4-64f7-472b-83fd-6a31780deac5 fwd="4.16.194.94" dyno=web.1 connect=0ms service=3ms status=404 bytes=429 protocol=https
2017-06-21T23:05:05.846086+00:00 app[web.1]: I, [2017-06-21T16:05:05.846002 #4]  INFO -- : [911403d4-64f7-472b-83fd-6a31780deac5] Started GET "/cable" for 4.16.194.94 at 2017-06-21 16:05:05 -0700
2017-06-21T23:05:05.846932+00:00 app[web.1]: I, [2017-06-21T16:05:05.846873 #4]  INFO -- : [911403d4-64f7-472b-83fd-6a31780deac5] Started GET "/cable/" [WebSocket] for 4.16.194.94 at 2017-06-21 16:05:05 -0700
2017-06-21T23:05:05.847023+00:00 app[web.1]: E, [2017-06-21T16:05:05.846970 #4] ERROR -- : [911403d4-64f7-472b-83fd-6a31780deac5] Request origin not allowed: https://anyperk-wellness.herokuapp.com/
2017-06-21T23:05:05.847112+00:00 app[web.1]: E, [2017-06-21T16:05:05.847051 #4] ERROR -- : [911403d4-64f7-472b-83fd-6a31780deac5] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
2017-06-21T23:05:05.847181+00:00 app[web.1]: I, [2017-06-21T16:05:05.847134 #4]  INFO -- : [911403d4-64f7-472b-83fd-6a31780deac5] Finished "/cable/" [WebSocket] for 4.16.194.94 at 2017-06-21 16:05:05 -0700
2017-06-21T23:06:04.870791+00:00 app[web.1]: I, [2017-06-21T16:06:04.870693 #4]  INFO -- : [748b96e8-217b-4435-9c7b-242f7924f69a] Started GET "/cable" for 166.137.242.115 at 2017-06-21 16:06:04 -0700
2017-06-21T23:06:04.871459+00:00 app[web.1]: I, [2017-06-21T16:06:04.871404 #4]  INFO -- : [748b96e8-217b-4435-9c7b-242f7924f69a] Started GET "/cable/" [WebSocket] for 166.137.242.115 at 2017-06-21 16:06:04 -0700
2017-06-21T23:06:04.871532+00:00 app[web.1]: I, [2017-06-21T16:06:04.871492 #4]  INFO -- : [748b96e8-217b-4435-9c7b-242f7924f69a] Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)

haozeng avatar Jun 21 '17 23:06 haozeng

Hi -- this package is deprecated and may not work with the latest versions of React. I recommend replacing with react-actioncable-provider which offers similar functionality using a higher-order component and is up to date with the latest versions.

schneidmaster avatar Jun 22 '17 00:06 schneidmaster

Hey guys! Consider using my fork: https://github.com/kesha-antonov/react-native-action-cable And also please mention it in the README

Seems like people love it

kesha-antonov avatar Feb 01 '18 06:02 kesha-antonov