WebSocket to localhost not working on Microsoft Edge - javascript

I've created a simple WebSocket server and am trying to connect to it with the following code:
function test(name) {
var ws = new WebSocket('ws://localhost:1234');
ws.onopen = function () {
ws.send('Hello from ' + name);
}
}
test('Edge');
This works fine from Chrome and IE11 on Windows10 but when I try from Edge, the onopen function isn't called, instead I eventually get the following error:
SCRIPT12029: WebSocket Error: Network Error 12029, A connection with the server could not be established
This is happening for version 12.10240 of Edge.
A similar problem was asked about here but the error message is different.
Things I tried:
IP - localhost, 127.0.0.1, the actual IP
Allow localhost loopback flag - both on and off
When trying to communicate with a different machine the problem does not occur.
Is this a defect in Edge or am I doing something wrong?

I had a similar problem, but it was when actually navigating to pages in the browser. I could use the phrase localhost and it worked fine, but I didn't work when I used my machine's name. I found this forum where they suggested that you run the following command in a administrator prompt:
CheckNetIsolation LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe
Worked for me. Thought you might be seeing some form of the same issue.
As the forum suggests, you can now also do this by opening Edge and navigating to "about:flags", then tick "Allow localhost loopback (this might put your device at risk)" under "Developer Settings". Should feel a little safer than pasting random stuff into your command prompt.
Edit: As tresf pointed out below, the loopback checkbox in the about:flags appears to have stopped working (as a fix), so you'll have use the CheckNetIsolation command, to make Edge exempt.

Related

SMART on FHIR client-js: Invalid Character Error on IE11

Note: The issue is also reported on GitHub. Please take a look at Git issue as well for current progress/investigation.
I'm using fhir-client v0.1.15 to develop a SMART on FHIR web application that would run in EHR launch scenario. For example in Epic Hyperspace simulator that uses IE to run the SMART application.
While testing my application locally(localhost) on IE11, I get a JavaScript error from within fhir-client.js.
SCRIPT1014: Invalid character
File: fhir-client.js, Line: 38113, Column: 3
Below are the two lines from code. 38112 & 38113 in order:
var ret = Adapter.get().defer();
var state = JSON.parse(sessionStorage[params.state]);
Any solution or workaround would be much appreciated.
Updated
Upon further investigation we found that sessionStorage is empty when line with JSON.parse executes. However, strange thing is why/how sessionStorage gets empty after redirection from authorization server. This only happens with IE11, everything works fine on Chrome though.
PS. Can someone please add a new tag SMART or SMARTonFHIR?
Though I couldn't find the exact root cause and solution but let me share the findings that helped me resolve this issue somehow.
The issue doesn't exist when I test my SMART application with redirect_uri(in FHIR.oauth2.authorize call) set to a staging server URL instead of localhost.
PS. I’m open to better, and more qualified answers for acceptance.

iOS: Javascript code in WKWebView got “query cancelled” error after selecting photo from photo library and before uploading to the server

I use Xcode 9.1(9B55), iOS 11.1 both simulator and real iPhone/iPad.
The website(HTML5+Javascript) I used in mobile safari acts perfectly. But in my iOS app(Objective-C), which uses WKWebView to access the same web page, and set all the "privacy - Photo Library Usage" and others, always got the error below after selecting photo from photo library and before uploading to the server:
[discovery] errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}
But something strange was that I had a successful run for just one time.
I've several threads about this issue, but have no clear solution. Someone said it's a bug of iOS 11.x, but I've tried it on iOS 9.x, the error was same.
I had the same issue on iOS 12.1. I spent a lot of time trying to figure out why I'm getting this error. I thought because of that error I can't upload an image to the server. But turned out on each try, the request fails with 401 status code because of permissions or additional http headers/cookies. In my case, this debug error meant nothing I thought(Maybe that's why additional argument OS_ACTIVITY_MODE = disabled in project scheme worked for other guys, because it just removed debug log from console). So, make sure you have a correct HTTP request with all permissions/headers as well. Maybe it will help you as It helped me. Good luck.

VS2015 error "Application is not currently attached to a script debug target that supports script diagnostics"

I created JS & HTML5 Blank App with Visual Studio 2015. When running it in VS debugger in "Local Machine" mode, I get the following error message:
Application is not currently attached to a script debug target that
supports script diagnostics
Just ignoring the error is not workable as at least breakpoints and console.log("text") do not work.
I'm having default options in VS.
I am running normal Win10, with automatic updates on.
Reinstallation of VS2015 did not solve the issue.
This worked for me although I was doing something slightly different. I got the same error message using IE 11 accessing a HTML file from my local file system (was mucking around with HTML). Seems IE developer tools don't much like this mode of operation (why?!). Here's my story...
File on my local windows laptop:
c:\temp\test.html
Can be opened in these browsers:
URL: file:///C:/Temp/test.html (in chrome)
URL: C:\Temp\test.html (in IE 11)
In Chrome tools commands in the console can be run no problem e.g.
console.log("hi");
In IE developer tools this fails with the message cited by the op.
I had a reverse proxy installed on my laptop (nginx) so tried serving the file up via HTTP and this fixed the issue with IE. Here's how I would access the file via HTTP via the proxy:
http://localhost:9092/temp/test.html
For reference here's my nginx.conf (but any other proxy would I expect work fine)...
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 9092;
server_name localhost;
location /temp {
alias "C:/temp/";
}
}
}
In my case (VS 2017 not 2015), the option shown below had somehow become unticked (I'm blaming an update). Before ticking this I was getting the same error as the OP; after ticking it, all is well again.
NB I'm debugging the Javascript within a WebBrowser control hosted in a Winform.
I finally got this solved with the help of Jack-Zhai in msdn forum. So, the summary of my journey:-
Problem:
- Running JS UWP blank app in debug mode & local machine w default settings in VS2015 generates a warning "Application is not currently attached to a script debug target that supports script diagnostics" into JavaScript console. Breakpoints do not work, adding console.log("here") does not write anything to console
Solution trial 1:
- changing and playing with VS2015 settings; the problem still exists
Solution trial 2:
- reinstalling VS2015; the problem still exists
Solution trial 3:
- reinstalling Windows10 - all applications deleted but user data not
- installing VS2015
=> Problem solved; debugging blank app works, and console.log("test") works

SSE not working as expected on Heroku

It is the first time for me working with Server Sent Events and probably I'm doing something wrong... I just followed a few guides and doing code experiments and locally everything seems to work fine.
Unfortunately when I upload the app on Heroku it doesn't work as expected.
The Javascript looks like this:
// SSE Start
// Check if SSE is supported
if (!!window.EventSource) {
var source = new EventSource('/live/redis');
} else {
console.log('SSE not supported');
}
source.addEventListener('open', function (e) {
console.log('Connection Open');
}, false);
I'm using NodeJS and Redis to get real time messages from the API, but it doesn't matter...
When the SSE connection is open I just print a log on the browser.
I do nothing else at moment and if I open my app locally it just work fine and I receive the console.log message.
If I push the project on Heroku I don't receive any open connection message.
I can not understand why, probably something is missing or probably do I need to configure Heroku to support SSE?
If I open the project with the command heroku local it works fine as well...
EDIT:
From the Heroku logs I receive this:
app/web.1: GET /live/redis 500 86.403 ms - -
I can not understand why, locally it is working fine, on Heroku it isn't.
The error is on my Node.js controller for the route /live/redis that start with this line:
// let request last as long as possible
req.socket.setTimeout(Infinite);
Changing it with the line below solved my problem:
// let request last as long as possible
req.socket.setTimeout(0x7FFFFFFF);
Now I don't know if it is the correct way, but for now it is working.

WebSocket onmessage() not being called when messages are sent

I'm using autobahn 0.4.10 (https://github.com/oberstet/Autobahn) as a WebSocket server to send messages to a Google Chrome Extension. I am able to open and close connections using WebSocket(), but when I call autobahn.websocket.WebSocketServerProtocol.sendMessage() the message appears to be sent but isn't delivered until the connection is closed.
The api for WebSocketServerProtocol's sendMessage() (derived from WebSocketProtocol) can be found here: http://www.tavendo.de/autobahn/doc/python/websocketprotocol.html#autobahn.websocket.WebSocketProtocol
Has anyone experienced this problem before?
The code I have been on the client side is (js):
ws = new WebSocket('ws://localhost:4444');
ws.onmessage = function(event) {
console.log('hii');
}
And on the server (python)...
#json is a string object
def sendEvent(self, json):
print 'to', self.peerstr
self.sendMessage(json, sync=True)
Both Autobahn and my version of Chrome (17.0.963.46) appear (from what I've gotten out of the headers and docs) to use version 13 of the WebSocket draft protocol.
Turns out this was a threading problem with some threads block the twisted reactor.
See:
http://groups.google.com/group/autobahnws/browse_thread/thread/6bf0c43ec169efc3#
http://twistedmatrix.com/documents/current/core/howto/threading.html
Autobahn works with Chrome (tested up to v19 .. Canary).
Could you try the
https://github.com/oberstet/Autobahn/blob/master/demo/broadcast/broadcast_server.py
demo to see if you have a general issue?
If that runs, direct your extension to that demo server .. it'll send you 1 tick per sec.
You can also enable debug output by changing the factory line to code like this
https://github.com/oberstet/Autobahn/blob/master/demo/echo/echo_server_with_logging.py#L50
2 more notes:
you don't need the sync = True option (it's really an advanced option .. mostly used with the Autobahn WS testsuite)
you might wanna join http://groups.google.com/group/autobahnws .. get answers more quickly .. I discovered your Q only by accident here
Disclosure: I am author of Autobahn and work for Tavendo.

Categories

Resources