-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
How to pass query parameters in react native WebSocket connection #16041
Comments
This issue looks like a question that would be best asked on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only. Will close this as this is really a question that should be asked on StackOverflow. |
I have the same problem. Anyone have a solution? thanks |
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Packages: (wanted => installed)
"react": "16.0.0-alpha.12",
"react-native": "^0.47.0",
Target Platform: iOS, android
Steps to Reproduce
I have a server where I can make a WebSocket connection. When a device makes a WebSocket connection (when the app starts/splash screen), the server looks for the query parameter in the URL, which has the auth token of the user and if the token is correct, the connection is approved, else connection is rejected.
This is how the code looks on the react native client side:
This works fine in my iOS emulator, and the iOS emulator has a WebSocket connection to mine server. However, I have an android phone (testing via LAN), and when I open the app, I get an error saying:
But, if I remove the query param from the URL
const socket = new WebSocket(
ws://${website});
This works fine, but since I cannot pass the token in the query params, I get an error from the server.
How can I pass query parameters to the WebSocket connection in android? Am I missing something?
The text was updated successfully, but these errors were encountered: