Вопрос

I am having issues with subscribing to my websocket server when I turn the secure option to true. I ran an SSL validator to make sure it was set up properly and everything passed. Also to be safe, I also checked with my hosting provider so I dont believe that is the issue. And also, everything does work when secure is set to false.

The WSS is running on port 8676, and I did make sure that port is open.

I am using the Stomp Javascript library. I downloaded the latest version from their github master branch (https://github.com/projectodd/stilts/blob/master/stomp-client-js/src/main/javascript/stomp.js).

I keep getting this error inside the _transmit() function: can't call transmit on undefined

It seems to not be setting the _transport property inside of _buildConnector() function. I added some console.logs and it always goes to the else statement in this function.

Any ideas on a fix? Or am I just missing something?

This is how I am initializing my connection:

client = new Stomp.Client('my.ip.address', 8676, true);

Here is where I am logging some of the functions:

Stomp.Client = function(host, port, secure) { console.log('host param: ' + host); console.log('port param: ' + port); console.log('secure param: ' + secure); this._host = host || Stomp.DEFAULT_HOST; this._port = port || Stomp.DEFAULT_PORT || 8675; this._secure = secure || Stomp.DEFAULT_SECURE_FLAG || false; console.log('this._host: ' + this._host); console.log('this._port: ' + this._port); console.log('this._secure: ' + this._secure); }

Output:

host param: my.ip.address port param: 8676 secure param: true this._host: my.ip.address this._port: 8676 this._secure: true

_buildConnector: function(transports, i) { console.log('INSIDE _buildConnector()'); var callback = this._connectCallback; var client = this; if ( i < transports.length ) { console.log('IF!!!'); return function() { var fallback = client._buildConnector( transports, i+1, callback ); try { console.log('_buildConnector::IF::TRY'); transports[i].connect( function() { client._transport = transports[i]; callback(); }, fallback ); } catch (err) { console.log('_buildConnector::IF::CATCH'); fallback(); } }; } else { console.log('_buildConnector::ELSE'); return client.connectionFailed.bind(this); } }

Output:

INSIDE _buildConnector() IF!!! INSIDE _buildConnector() IF!!! _buildConnector::IF::TRY INSIDE _buildConnector() _buildConnector::ELSE _buildConnector::IF::TRY

connectionFailed: function() { console.log('INSIDE connectionFailed()'); if (this._errorCallback) { console.log('connectionFailed::IF'); console.log('this._errorCallback'); console.log(this._errorCallback); console.log('arguments'); console.log(arguments); this._errorCallback.apply(this._errorCallback, arguments); } else { console.log('connectionFailed::ELSE'); console.log('unable to connect :('); Stomp.logger.log( "unable to connect" ); } }

Output: No output..

Это было полезно?

Решение

I discovered this node.js tool called wscat which can be used to send messages to a websocket server (http://einaros.github.io/ws/).

When entering the command using the external address: wscat -c wss://my.ip.address:8676

I kept getting the following error: error: Error: Hostname/IP doesn't match certificate's altnames

But when I changed it to my domain name: wscat -c wss://mydomain.com:8676

I was given this message: connected (press CTRL+C to quit)

Which led me to:

I am setting the host value in Javascript as the external ip address of the server where STOMP lives. But the SSL cert is configured for a domain name. This led me to think that I should use mydomain.com instead of my.ip.address for the host parameter in new Stomp.Client. But this is resulting in the following error in the Torquebox log file:

NoSuchHostException: No such host: mydomain.com

So then in the torquebox.yml file the host property needed to be configured to mydomain.com as well.

So the conclusion is: You need to use the domain name that was registered to the SSL cert when trying to connect to your websocket server, not the external ip address. huzzah!

Credit to: @bobmcwhirter who helped lead me to this solution here: https://github.com/projectodd/stilts/issues/20

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top