Page 1 of 1

got the error using sockets

PostPosted: 04. October 2022 18:59
by vr2000
I have XAMPP installed. I'm testing a chat using sockets on localhost and got the error "WebSocket connection to 'wss://localhost:9443/chat/server.php' failed".
I read how to connect a socket in XAMPP. I have the socket connected in the php.ini file, but I get an error.
Why sockets do not work even though they seem to be connected?

Re: got the error using sockets

PostPosted: 05. October 2022 09:45
by IamCarry
Same issue happened with me also.

Re: got the error using sockets

PostPosted: 05. October 2022 18:57
by vr2000
My condolences. I wonder if anyone knows how to deal with this?

Re: got the error using sockets

PostPosted: 05. October 2022 21:26
by Froosh
Can't say I've used web sockets with XAMPP, but is XAMPP/apache and whatever services used by your application running when you are loading the URL?
Are you attempting to load the URL from the localhost that actually has the application servicing the web socket application?
Was this application working on your system at any point, and if so, what changed?

For background, I have the version 8.1.10 of XAMPP running on Windows 11, and it is able to server http/https just fine, so I know this version is working. I do not have a web sockets application installed to match your specific setup, so not sure what you could try, or what else to ask.

Re: got the error using sockets

PostPosted: 05. October 2022 22:08
by vr2000
Thanks for your answer.

Yes, I also just replaced the old XAMPP with XAMPP for Windows 8.1.10 and I also have windows 11.

I generally write WordPress plugins and use XAMPP to test them. And WordPress runs on XAMPP.

Yes, I have this code:
Code: Select all
 var socket = new WebSocket("wss://localhost:8090/wwwchat3/server.php");

and the server.php file is indeed in the project folder.

I recently started learning about sockets. I downloaded an example application with sockets. I put this application on XAMPP and I see the error that I wrote about earlier. I also placed this application on a real hosting and it works there and does not give an error.

Re: got the error using sockets

PostPosted: 06. October 2022 00:18
by Froosh
I know WP works with XAMPP, I use that it for that, too.

Have you confirmed the Apache configuration, and possibly bits of XAMPP have not changed with updating to 8.1.10. I usually make a backup of this stuff prior to installing a new version, as I am not sure that my customized settings configuration is preserved.

I've personally not tried using web sockets with XAMPP. If you did any configuration of XAMPP and Windows Firewall, I would verify that those are still in place. Other than that, not sure what else to suggest at this point.

Re: got the error using sockets

PostPosted: 06. October 2022 16:34
by Nobbie
Its not sufficient to call the PHP server script in a browser only, you also have to run it in CMD Shell (where it act as server). See also https://stackoverflow.com/questions/473 ... mpp-server

Re: got the error using sockets

PostPosted: 07. October 2022 11:42
by vr2000
Thanks for the answer. Yes, I tried to start the server through CMD Shell, but the sockets still do not work. Looks like I need to read more about them.