I have a problem that seems to me to be impossible to solve, well, I have a website on EC2, I bought my own domain, I added HTTPS using Let's encrypt, and on this website there is a chat, and I am using the PHP Ratchet library to create a connection with websockets, and the problem is that my server doesn't start in the browser, well, I've tried to make my server start with several ports, 3000, 8080, 8181, 8443, 4433, and none of these work, at least when I use the command php chat-server.php to start the PHP server, I don't get any errors, it works, however, when entering the browser, it doesn't display a message in the PHP script console saying that there is a new connection, and the browser console ( chrome) reports a timed out error, that is, it looks like you are not connecting to the server, I really don't know what to do anymore, I don't know if this is because of the HTTPS I'm using, I don't know if should I edit something in the apache configuration, I need the someone help me, please
In fact, I already edited the security group in EC2, I already enabled these ports that I said I tried to use, I restarted the Apache server too and I still get the same error
PHP CODE - chat-server.php :
<?php
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use Local\Socket\Chat;
require dirname(__DIR__) . '/vendor/autoload.php';
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
4433
);
$server->run();
JS CODE:
var conn = new WebSocket("wss://example.net:4433/chat.php");
ERROR:
failed: Error in connection establishment:
net::ERR_CONNECTION_TIMED_OU
Related
I have problem with connection to RabbitMQ server (version: 3.8.2, erlang version: 22.2.8) by JS (on browser) webstomp. I'm using stomp.js.
I'm using example from here: https://github.com/rabbitmq/rabbitmq-web-stomp-examples/blob/master/priv/echo.html
I've done everything like is described here: https://www.rabbitmq.com/web-stomp.html
I've set permissions to my user using this: sudo rabbitmqctl set_permissions -p / user ".*" ".*" ".*"
I've set tags to my user using this: sudo rabbitmqctl set_user_tags user management
I've already checked these solutions:
Failing to connect RabbitMQ through a EasyNetQ, getting access refused for user guest and
RabbitMQ - access to vhost 'XXX' refused for user 'guest',
and others that I found in google.
My configuration for rabbitmq_web_stomp:
{rabbitmq_web_stomp,
[
{tcp_config, [{port, 15674}
]
},
{use_http_auth, true},
{ssl_config, [{port, 15673},
{backlog, 1024},
{cacertfile,"path/to/cert"},
{certfile,"path/to/cert"},
{keyfile,"path/to/cert"},
{password, "pass"}
]
}
]
},
I always get the same response from server:
Opening Web Socket...
Web Socket Opened...
>>> CONNECT login:user passcode:pass host:/ accept-version:1.1,1.0 heart-beat:10000,10000
<<< ERROR message:Bad CONNECT content-type:text/plain version:1.0,1.1,1.2 content-length:32 Access refused for user 'guest'
Whoops! Lost connection to ws://ip.addres/ws
I have access (for this user) to the server by .NET Core client in C# and by Management Plugin
Thanks for help!
I found the solution.
I don't exactly sure why it works but it was enough to remove the {use_http_auth, true} from configuration. After that there was no problem with connection from JS from browser.
I have the following script through which I am trying to connect to openfire using WebSocket built in Firefox.
index.js
console.log(window.WebSocket);
var exampleSocket = new WebSocket("ws://localhost:5222/")
but it shows me the following error on browser console.
Firefox can’t establish a connection to the server at
ws://localhost:5222/.
can anybody tell me what I am doing wrong or there any other better way of doing this. I am using the latest version of Firefox.
First of all, make sure you have installed Openfire WebSocket plugin in the Openfire. so first check it's availability in plugins available. and then write the code as follows.
var exampleSocket = new WebSocket("ws://localhost:7070/ws/",'xmpp')
XMPP is the protocol for openfire
in case you want to check for the error you have to do like this.
exampleSocket.onerror = function(data){
console.log(data);
}
I'm developing a Progressive Web App which uses a .manifest file to cache all files on the client. I modified the socket.io chat example which is found here:
https://github.com/socketio/chat-example
my modifications can be found here:
https://github.com/TennisVisuals/socket.io.manifest.errors
The first change in the client code is:
external resources (jquery and socket.io client libraries) are accessed locally rather than via remote URLs.
Everything works as expected.
But with the second change:
<html> is replaced with <html manifest="index.manifest">
The application fails, giving this error in the Javascript console:
http://localhost:3000/socket.io/?EIO=3&transport=polling&t=Lij1LRo net::ERR_FAILED
Initial Fix
I've been able to make it work locally by adding the following lines:
enter var connectionOptions = {
"force new connection" : true,
"reconnectionAttempts": "Infinity",
"timeout" : 10000,
};
var socket = io(connectionOptions);
Cloudflare and Nginx
But I'm now seeing stranger behavior when I run with Cloudflare and Nginx.
Without the manifest declaration I get an error, but everything still works!
socket.io-1.7.2.js:7370 WebSocket connection to 'wss://hiveeye.net/socket.io/?EIO=3&transport=websocket&sid=rM2LKvCGJwaFx7RrAAAf' failed: Error during WebSocket handshake: Unexpected response code: 400
after adding the manifest declaration it works exactly once and then fails with the following errors:
socket.io-1.7.2.js:4948 GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5SC5&sid=rM2LKvCGJwaFx7RrAAAf net::ERR_FAILED
GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5STN net::ERR_FAILED
GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5STN net::ERR_FAILED
I suspect that if I can get the initial error to go away when running without the manifest, that may do the trick... but I've been unable to find anything to help me resolve that issue...
Ok, this was really simple once I found out how to ask the right question
Adding:
NETWORK:
*
at the bottom of the manifest file made everything work.
Yes, the "Application Cache" is deprecated:
https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache
but I still wanted to make it work!!
I have a socket.io implementation, and I'm trying to make it work across domains but it appears it can't. Here's my exact use case:
I have a node.js server running socket.io.
I have a JS / HTML5 game that I want to be able to host from anywhere, which has the client socket.io code and tries to connect to the server.
I have the same JS code running on mobile devices via SpiderMonkey (this is one of the main reasons I need to run this from any domain).
I find that I simply cannot connect to the socket unless I am serving the JS code from my node.js server to a browser. If I simply open the HTML file on my disk from my browser, for example, it will not work.
Server code:
io.on( "connection", function( socket )
{
this.socket = socket;
this.socket.on( "echo", function( str ){ this.socket.emit( "message", str ); }.bind( this ) );
}.bind( this ) );
Client code:
this.socket = io.connect( ip );
this.socket.on("message", function( str ) { console.log( str ); } );
And I can't even connect, I get my print out that it's trying to connect, but it never succeeds and then starts throwing ping errors. So, is this even possible? Or must I do it with long polling or something?
The error:
[Error] Failed to load resource: A server with the specified hostname could not be found. (socket.io, line 0)
EXTRA INFO:
This specifically will not work if I am trying to connect from an HTML file opened from disk using file:///. I am going to try across different machines on the same network...
Yes, Socket.IO works cross-domain just fine. The actual Socket.IO library can/should be loaded from the server hosting it.
EXTRA INFO: This specifically will not work if I am trying to connect from an HTML file opened from disk using file:///.
Don't do that. You run into all sorts of weird issues when loading files off disk vs. over HTTP.
Failed to load resource: A server with the specified hostname could not be found.
This usually implies that whatever hostname you're trying to connect to isn't resolvable, indicating a DNS problem or that you typoed your hostname. In any case, your code example doesn't show the relevant part where the problem may be. Use your browser's developer tools to first determine that everything is loading correctly. Then, verify the address of what you're trying to connect to.
using the answer of my previous question and another post I tried to implement facebook-chat from a browser. Here is what I did:
on an ubuntu virtual machine, I have python 2.6.5, python-twisted-conch 1:10.0.0-2, python-twisted-names 10.0.0-1, python-twisted-web 10.0.0-1 and python-twisted-words 10.0.0-2 already installed. I did not install jabberd2 server, I assumed facebook server is the Jabber/XMPP server in my case. Also I did not install pyopenssl.
downloaded and untared punjab from here
run it using the following command
user#ubunto: sudo twistd punjab
sometimes it tells that the process is already running under PID xxx but most times the reply was
Removing stale pidfile /home/user/twistd.pid
Does this mean that punjab is running?
In the punjab.tac file, according to this post I change the root.putChild line to
root.putChild('bosh', b)
On the other hand, I have an apache server running on the host computer (windows xp) to host my webpage that uses Strophe. In the apache config file httpd.conf, I proxy the BOSH requests to punjab at port 5280 using:
<IfModule proxy_http_module>
ProxyRequests Off
ProxyPass /bosh http://ubunto_ipAddress:5280/bosh
ProxyPassReverse /bosh http://ubunto_ipAddress:5280/bosh
</IfModule>
Note that the host and the virtual machine are bridged, so both get their IP address from the router and each one can ping the other. I also didn't install a jabber/xmpp server, or
For testing, I use the basic example of strophe as my webpage basic.html and basic.js with JID: FB_username#chat.facebook.com & password: FB_password.
I get the following:
Strophe is connecting.
SENT: <body rid='1709425072' xmlns='http://jabber.org/protocol/httpbind' to='chat.facebook.com' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>
Strophe is disconnecting.
Is there anything wrong or missing? Please help since I am not finding real documentation other than some posts concerning this issue. Thanks
Sabah
I'm not certain this is what you're trying to do, but if you're trying to have a webpage independently connect to Facebook Chat via JS, it's not going to work due to Cross Site Scripting protections. You can only use Strophe to connect to the same server that issued the webpage Strophe is working on. You'll have to connect back to your server first and use that as an inbetween; or use iframes to embed facebook chat in your webpage.
(For the record, I know nothing about Python, but it looks like your problem is with the JS :) )