Giter Site home page Giter Site logo

Comments (13)

ArvyRogerio avatar ArvyRogerio commented on June 27, 2024 3

Found the problem! Maybe help @winternet-studio or others.

The problem was not on Textalk. The server (Nginx) was missing the intermediate certificate. Checked using https://www.sslshopper.com/ssl-checker.html.

To fix: on Nginx "ssl_certificate" must point to a file with the certificate concatenated with the CA certificate. Just "cat cert.pem ca.pem > output.pem" and use it on Nginx. Same thing on Apache, on "SSLCertificateFile".

Using Let's Encrypt, just use fullchain.pem instead of cert.pem.

from websocket-php.

sandy5623 avatar sandy5623 commented on June 27, 2024 3

I too had the same issue with localhost wss:// Below code worked for me for byepassing certificate validation
stream_context_set_option($context, 'ssl', 'verify_peer', false); stream_context_set_option($context, 'ssl', 'verify_peer_name', false);

from websocket-php.

bennetgallein avatar bennetgallein commented on June 27, 2024

If you can provide some code we'll can help. wss:// works fine for me with apache2 default and php7.0

from websocket-php.

ArvyRogerio avatar ArvyRogerio commented on June 27, 2024

I'm having the same problem, but it shows error on line 60, not on 95.

The server is ok, running wss, and Chrome can connect.

My server is a Nginx running SSL via proxy.

Fatal error: Uncaught exception 'WebSocket\ConnectionException' with message 'Could not open socket to "xxxxx:443": (0).' in /.../textalk/websocket/lib/Client.php:60

from websocket-php.

winternet-studio avatar winternet-studio commented on June 27, 2024

ssl-checker didn't indicate any problems on my server - it says "all the correct intermediate certificates are installed" and everything else is green as well. I'm also using Let's Encrypt.

Not sure what code to share. I try to connect to the server using this standard code:

$client = new WebSocket\Client('wss://mydomain.com/wss2/', array('timeout' => 10));

In Javascript this code works fine:

var connection = new WebSocket('wss://mydomain.com/wss2/');

If you contact me through my website I can let you know the actual server so you could try it yourself if you're interested.

from websocket-php.

nssmart avatar nssmart commented on June 27, 2024

Hi,

I have the exact same configuration with nginx proxying ssl to :8000 websocket server, can connect from browsers, but not from the server itself.

Was wondering whether you've had any luck figuring it out?

Thanks in advance!

from websocket-php.

winternet-studio avatar winternet-studio commented on June 27, 2024

Sorry, I have not tried anything or found any solutions since my post.

from websocket-php.

nssmart avatar nssmart commented on June 27, 2024

Thanks for the reply.
Pity it is.. anyone else perhaps?

from websocket-php.

winternet-studio avatar winternet-studio commented on June 27, 2024

I've now picked this up again and I found out that it didn't work on my Windows developer machine, but the same code worked fine on a production Linux server. I also tried an asynchronous client https://github.com/ratchetphp/Pawl which also had issue on my local machine but worked fine on Linux server. Hopefully this bit of info might be helpful to someone.

from websocket-php.

nssmart avatar nssmart commented on June 27, 2024

I figured it out as well, here is the deal.

  1. We were using Nginx+Apache configuration on the server.
  2. Nginx was configured so that it made an ssl-handshake with client and then internally redirected request to websocket's apache port (like 8080).
  3. So when connecting from clients (JS) we used WSS and it worked - their requests came to nginx that handled SSL and forwarded them to Apache.
  4. However, when connecting from the same machine from php script, it didn't work.
    What worked was connecting to the apache server directly (WS to port 8080 in this example).

Hope this will help someone as well :).

from websocket-php.

karimhb avatar karimhb commented on June 27, 2024

I had the sane issue. The problem was that I am restricting access to ws to the origins "localhost" and "our domain". This library doesn't send an origin in the header. Got it fixed by adding
'origin' => 'localhost'
in the $header array in ~ 107 vcendor/texttalk/websocket/lib/Client.php

from websocket-php.

saeed-khalafinejad avatar saeed-khalafinejad commented on June 27, 2024

For me also bypassing the SSL worked....

from websocket-php.

balap777 avatar balap777 commented on June 27, 2024

I too had the same issue with localhost wss:// Below code worked for me for byepassing certificate validation stream_context_set_option($context, 'ssl', 'verify_peer', false); stream_context_set_option($context, 'ssl', 'verify_peer_name', false);

hello @sandy5623 it would be great help if you can share the full code as tried the above but unable make it work and also the latest version gives array error in second parameter so not able to figure out how to use above code thanks in advance

from websocket-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.