question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebSocket inside WebView?

See original GitHub issue

Is there any reason a WebSocket wouldn’t work? I get crickets, while the same code works from the main RN app.

 <WebView
        originWhitelist={['*']}
        injectedJavaScript={`

var exampleSocket = new WebSocket('ws://localhost:3000')

exampleSocket.onopen = function (event) {
  window.ReactNativeWebView.postMessage("onopen")
}

exampleSocket.onerror = (e) => {
  window.ReactNativeWebView.postMessage('onerror')
}

exampleSocket.onmessage = (e) => {
  window.ReactNativeWebView.postMessage('onmessage')
}

        `}
        source={{ html: '<html><body></body></html>' }}
      />

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
benallfreecommented, May 3, 2021

Would love to hear from a maintainer on this issue 😃

0reactions
ordinaryprobablycommented, Jun 14, 2022

I am having the same issue.

If I open the webview url in my macbook chrome, server catches the socket connection.

But nothing hits the server when I open it on my RN webview…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why android webView is not supporting webSocket?
In my application I am using webView to call a URL. My website is using web Socket to change values. when i open...
Read more >
Android – WebSocket in Android WebView - iTecNote
I used this project to demonstrate how to use PhoneGap with Pusher on Android but ultimately it's just a project that happens to...
Read more >
WebSockets in WebView dropping/hanging (but not explicitly ...
Expected result: I have a web app that runs on websockets (SockJS) talking to a python backend. It works flawlessy in the browser...
Read more >
WebSocket - Web APIs
Chrome Edge Internet Exp... WebSocket Chrome Full support 4 Edge Full support 12 IE Full supp... WebSocket() constructor. ⚠️ Chrome Full support Yes Edge Full...
Read more >
Web Socket issue in Safari/WebView… - Apple Developer
Web Socket issue in Safari/WebView on iOS 15/macOS Monterey ... In our web app, we use the MQTT library which internally uses a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found