I have an Angular 6/.NETCore ASP.NET Boilerplate application which uses SignalR to allow the server to execute some client code. The version of the Abp.AspNetCore.SignalR library is 3.5.0-preview3, which uses Microsoft.AspNetCore.SignalR version 1.0.0-preview1.
The SignalR management code is the one shipped in the official template of ASP.NET Boilerplate.
Everything works fine during the development in Visual Studio with IIS Express.
Now I have published the application on a Windows Server 2008 R2, which ships an IIS 7 server. The application starts up but in the Chrome console I see this error:
signalr.min.js:13 WebSocket connection to 'ws://MY-HOSTNAME:21021//signalr failed: Error during WebSocket handshake: Unexpected response code: 400
signalr.min.js:13 Error: Failed to start the connection. undefined
The same problem occurs on Edge:
Starting connection using WebSockets transport abp.js (350,1) Error:
Failed to start the connection. undefined signalr.min.js (13,25649)
SCRIPT12008: SCRIPT12008: WebSocket Error: Incorrect HTTP response.
Status code 400, Bad Request
Here I can see that SignalR is supported in Windows Server 2008 R2, even though it is not supported in IIS 7 (8 is required). It's also written that SignalR is supposed to fallback to some other protocol in case the server does not support WebSocket (my situation).
It is strange that the browser is trying to use the WebSocket protocol, even though it is not supported by the server.
Do you have any clue for this problem? May I be missing something?
UPDATE
I upgraded all the ASP.NET boilerplate libraries to 3.8.1, including the SignalR library.
The error does not show up, so it is a old bug of previous versions.
Now I have this console log:
Starting connection using WebSockets transport
Failed to start the connection: Error: Unable to initialize any of the available transports.
Cannot start the connection using WebSockets transport. Unable to initialize any of the available transports.
Starting connection using ServerSentEvents transport
Information: SSE connected to http://MY-HOST:21021//signalr?asdasdasd
Connected to SignalR server!
Registered to the SignalR server!
So at first it tells that it fails connecting though SignalR with any protocol, but then it succeeds with the ServerSentEvents protocol.
Is it connecting or not?
The version of the Abp.AspNetCore.SignalR library is 3.5.0-preview3, which uses Microsoft.AspNetCore.SignalR version 1.0.0-preview1.
Upgrade to Abp.AspNetCore.SignalR 3.7.0+ (current: 3.8.2) for a stable release version.
So at first it tells that it fails connecting though SignalR with any protocol, but then it succeeds with the ServerSentEvents protocol. Is it connecting or not?
As it says, it is connected using the ServerSentEvents transport. You can see why here:
abp.log.debug('Cannot start the connection using ' + signalR.HttpTransportType[transport] + ' transport. ' + error.message);
if (transport !== signalR.HttpTransportType.LongPolling) {
return start(transport + 1);
}
The error.message ("Unable to initialize any of the available transports.") is a little misleading because only one transport is specified at a time.
Related
I've done quite a bit of reading around to try and solve this issue but I'm still stuck. My problem is with trying to get the websocket handshake to complete using socket.io client side and flask_socket.io server side.
I can run the flask development server on my local machine using:
app = Flask(__name__)
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
socketio = SocketIO(app)
socketio.run(app)
...
and if I point chrome to localhost:5000 and press the button which I have linked to opening a websocket it works fine and chrome network tab shows status 101.
However on uploading the code to a remote machine and again using flask's development server but changing the port to 80,
socketio.run(app,host='0.0.0.0',port=80)
the websocket handshake stops working and gives status 200 instead.
WebSocket connection to 'ws://example.com/socket.io/?EIO=3&transport=websocket&sid=cfb1949b243b42578fe422782a0db359' failed: Error during WebSocket handshake: Unexpected response code: 200
All websocket messages are now sent over xhr polling instead of inside the websocket frame.
I've followed all of the guides I can find on google relating to this but with no success. I was previously using nginx and gunicorn and followed the advice to change the nginx conf to allow upgrade to websockets but that didn't solve the problem. So I simplified to using the flask development server but I still haven't been able to get a successful handshake.
I found a solution after finding a similar problem posted here https://nolanlawson.com/2013/05/31/web-sockets-with-socket-io-node-js-and-nginx-port-80-considered-harmful/#comment-85425.
It turns out many public wifi networks block websockets when they are running on port 80. However often ports 443 and 8080 are not blocked. You can find out which ports are blocked from this website: http://websocketstest.com/. I just moved the address of my websocket from example.com to example.com:8080.
I ran into a similar problem but due to a different reason. When using flask-socketio you have to install gevent-websocket or else it's going to use long-polling and you'll see a lot of 200 responses. Thus, my solution to that problem was just.
pip install gevent-websocket
I am trying to use Paho's JavaScript library to connect to a Mosquito MQTT server. I have just used the example on the Paho website. Which is:
function onConnect() {
console.log("onConnect");
client.subscribe("harleyRowland/myTopic");
message = new Paho.MQTT.Message("Hello");
message.destinationName = "harleyRowland/myTopic";
client.send(message);
}
onConnect();
On Safari, I get the following error:
Error: AMQJS0011E Invalid state not connected.
and on Chrome, I get the following error as well as the one above:
WebSocket connection to 'ws://mosquitoServer.co.uk:1883/mqtt' failed:
Error during WebSocket handshake: net::ERR_CONNECTION_RESET
I need to use the Mosquito server for this work. Is it possible using JavaScript? If it isn't possible, is there another web technology I could use?
You need to add a websockets listener to your mosquitto setup. you do this by adding something like the following to your mosquitto.conf
listener 1884
protocol websockets
This will listen for MQTT over websockets on port 1884 (not 1883 as you can not run both on the same socket with mosquitto).
You will also need to be running mosquitto newer than 1.4 and not on Windows unless you compile it yourself
I'm trying to connect the Mongo shell with Mongolab. I am using my mongolab username and password but it is giving an error: "Failed to connect to 54.81.180.188:56789."
My userName and password is correct.
I'm using Windows 8.1
When I ping ds0-----.mongolab.com that's working fine.
C:\mongodb\bin>mongo ds0----.mongolab.com:56789/dbname -u "MyUserName" -p "MyPassword"
MongoDB shell version: 3.0.3
connecting to: ds027751.mongolab.com:56789/dbname
2015-06-05T10:55:30.019+0530 W NETWORK Failed to connect to 54.81.180.188:56789, reason: errno:10061 No connection could be made because the target machine actively refused it.
2015-06-05T10:55:30.024+0530 E QUERY Error: couldn't connect to server ds027751.mongolab.com:56789 (54.81.180.188), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
I had the same problem, my server abruptly lost the ability to connect to MongoLab. I contacted support, who sent this reply:
Hello,
Your Experimental Sandbox plan is running MongoDB 3.0.x, which
includes changes to Mongo's authentication mechanism. This new
mechanism is supported by certain newer driver versions, as described
at
http://docs.mongodb.org/manual/release-notes/3.0-scram/#upgrade-drivers.
To connect to this database, you will need to use one of the drivers
listed at the above link.
Please let us know if you have questions about this.
Sincerely, Samson
I assume I was upgraded automatically, as I hadn't touched the server code or MongoLab in months. As an immediate fix, I just created a new db in MongoLab, which was created in mongod v2.6.9 (I don't remember seeing an option to choose the version).
The JBoss AeroGear JavaScript notifier is a collection of adapters which provide a unified/similar API for interacting with different messaging services and protocols.
Issue
I'm writing some QUnit tests for the JBoss AeroGear JS MQTT over WS adapter which depends on the Eclipse Paho MQTT JavaScript client. The tests work on Firefox/Chrome but fail on PhantomJS 1.9.7 with AMQJS0008I Socket closed connection error.
Initially, my tests were running against an Apache Active MQ broker version 5.9.0 which supports MQTT over WebSockets out of the box. I've also modified them to use the Eclipse Paho MQTT over WebSockets sandbox environment ws://iot.eclipse.org/ws but the problem still exists.
How to reproduce?
Clone my GitHub repository https://github.com/tolis-e/aerogear-js-integration. Checkout the stackoverflow branch, execute npm install and then grunt integration-iot --debug. In order to verify that the tests are working on Firefox/Chrome, open the tests/notifier/mqttws.html in a browser. The QUnit tests are located inside the mqttws.js file. As you can see at the logs below, I'm getting a AMQJS0008I Socket closed error.
Any idea about the error cause? My sense is that the issue is related to the fact that PhantomJS 1.9.7 does not support Web Sockets RFC 6455. It looks like RFC 6455 will be supported by PhantomJS 2.x
Logs
[D] ["phantomjs","qunit.begin"]
[D] ["phantomjs","onLoadFinished","success"]
[D] ["phantomjs","qunit.moduleStart","Connect / Disconnect"]
[D] ["phantomjs","qunit.testStart","Connect to and Disconnect from MQTT Server"]
[D] ["phantomjs","console","Unexpected response code: 404"]
Unexpected response code: 404
[D] ["phantomjs","console","Connection error: AMQJS0008I Socket closed."]
Connection error: AMQJS0008I Socket closed.
[D] ["phantomjs","fail.timeout"]
I have a WorkerRole configured to start node.exe via the Runtime/EntryPoint/ProgramEntryPoint element in the csdef and have a HttpsIn EndPoint configured for https on port 443 w/ a valid certificate. I'm also setting the PORT environment variable in Runtime/Environment which is used by node to listen on for incoming requests.
When I start the service (either in local dev fabric or in Azure) and try to hit the service I get the following error:
SSL connection error
Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have.
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.
I have verified that node.exe is indeed started when the service starts, and if I look up the local port in the Compute Emulator, usually something like:
http://localhost:444
I am able to successfully hit node directly with that using my browser. I am also able to hit node through Azure when SSL is not configured.
What am I missing? Thanks!
The issue was that I was using the http module instead of the https module when starting the web server in Node. Works once I started the https server using the ssl certificate.
I was following a guide for SSL w/ Node in a WebRole, which requires a different set up than SSL w/ Node in WorkerRole.