Skip to content

WebSocket URL property undefined #25260

Closed
@tegandbiscuits

Description

@tegandbiscuits

The properties url, protocol, and bufferedAmount on instances of WebSocket are returning undefined (on iOS at least).

I'm able to successfully connect using both of the given values, but accessing either doesn't work as expected. This causes problems for clients that depend on having either value.

However, readyState seems to be working correctly. I haven't checked extensions.

React Native version:

  React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      Memory: 62.36 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.15.3 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5522156
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.9 => 0.59.9
    npmGlobalPackages:
      react-native-cli: 2.0.1

Steps To Reproduce

  1. Create a new WebSocket that uses a subprotocol
  2. After connecting, attempt to access url or protocol

Describe what you expected to happen:

If I do const ws = new WebSocket('ws://localhost:8080, 'some-protocol')`

ws.url and ws.protocol should return ws://localhost:8080 and some-protocol respectively.

Snack, code example, or link to a repository:

https://github.com/NRauh/react-native-websocket-issue

Here's a minimal example of a ws server and clients. The browser client works as expected, but the react native app does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugStaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions