Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On VPS IoServer works (HttpServer -> WsServer) Doesnt #998

Open
sloflo opened this issue Feb 4, 2023 · 7 comments
Open

On VPS IoServer works (HttpServer -> WsServer) Doesnt #998

sloflo opened this issue Feb 4, 2023 · 7 comments

Comments

@sloflo
Copy link

sloflo commented Feb 4, 2023

$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
9005,
'0.0.0.0'
);
$server->run();

I wrote the following proxy. To add upgrade headers. I can see the raw headers when I run Ratchet only using IoServer::factory. So I know my request reaches the code. Once I add the HttpServer->WsServer code It no longer works. Port opens and is listening but websocket client will not connect.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wss [NC]
RequestHeader set Connection "Upgrade"
RequestHeader set Upgrade "websocket"
RewriteRule /wss/(.*) wss://127.0.0.1:9005/$1 [P,L]

@WyriHaximus
Copy link

You are listening on port 8080 while you rewrite from nginx to port 9005.

@sloflo
Copy link
Author

sloflo commented Feb 4, 2023

@WyriHaximus Sorry thats a typo. I was trying different ports. They all have the same result.

@sloflo
Copy link
Author

sloflo commented Feb 4, 2023

Additionally I was able to reach the websocket server by changing my proxy to redirect to ws. instead of wss. But my browser immediately closes the connection with a 1006 code

@WyriHaximus
Copy link

It's a bit harder to read without syntax highlighting 😅 . But you are also making a secure websocket connection instead of a plain text websocket connection and I don't see any certificate configuration in your PHP code

@sloflo
Copy link
Author

sloflo commented Feb 4, 2023

@WyriHaximus Will work on that and report back. Thank you!

@sloflo
Copy link
Author

sloflo commented Feb 5, 2023

Sigh no luck. Cant reach the websockets server once I add a SecureServer. Also tried port 8080

`$loop = Factory::create();

$ws = new WsServer(new Chat($loop));
$ws->enableKeepAlive($loop);

$http = new HttpServer($ws);
$webSock = new Server('0.0.0.0:9005', $loop);
$socketServer = new SecureServer(
    $webSock,
    $loop,
    [
        'local_cert' => '***',
         'local_pk' => '***',
        'allow_self_signed' => true,
        'verify_peer' => false
     ]
);
$server = new IoServer($http, $socketServer,$loop);
$server->run();`

@WyriHaximus
Copy link

Have you tried the other way around first? Just plain text before you dive into setting up a secure server? TLS adds an additional debugging layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants