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

Can't seem to connect to any websocket server #37

Closed
Akhawais opened this issue Aug 12, 2016 · 16 comments
Closed

Can't seem to connect to any websocket server #37

Akhawais opened this issue Aug 12, 2016 · 16 comments

Comments

@Akhawais
Copy link

Akhawais commented Aug 12, 2016

Hey there, using latest version (v0.2.2) and can't seem to connect to any websocket server at all.

Tried using echo.socketo.me:9000 and echo.websocket.org (using the first example on the README.md of this repo).

Most of the times I've tried I've just got no output from the console although twice I did get this outputting on the console:

Could not connect: HTTP/1.1 200 OK
Date: Fri, 12 Aug 2016 20:04:59 GMT
Server: Apache
Last-Modified: Mon, 19 Oct 2015 15:08:14 GMT
ETag: "222-dbe-5227683b37091"
Accept-Ranges: bytes
Content-Length: 3518
Connection: close
Content-Type: text/html; charset=UTF-8

(Pretty sure that the server I connected with when that outputted does not run Apache at all which is confusing)

I've tried on another computer, using a different Internet connection and didn't work. Although I can connect to them using my browser's built-in client and also Python so I am sure the issue is with Pawl.

Using PHP7 - can provide extra info if required.

Thanks.

@mbonneau
Copy link
Member

@Akhawais - I just created a new project using the simple example in the README and was able to connect to ws://echo.socketo.me:9000 and get the echoed text.

I am using php 7.0.5 with Pawl version 0.2.2. Could you post a gist of your code?

@Akhawais
Copy link
Author

Akhawais commented Aug 12, 2016

@mbonneau
Copy link
Member

I just pasted that code into my project (I changed the require path but that is it) and it worked fine for me. I am not sure what would cause that to fail unless you are behind a firewall or proxy of some sort.

@Akhawais
Copy link
Author

Not sure why it's failing either. Ratchet was working fine 2 days ago. I'm able to connect to WS via other clients on the same machine and even trying Ratchet on a different machine and internet connection doesn't work.

@mbonneau
Copy link
Member

Here is the output of my composer info - maybe there is some underlying library version that is different?

evenement/evenement v2.0.0  Événement is a very simple event dispatching library for PHP
guzzlehttp/psr7     1.3.1   PSR-7 message implementation
psr/http-message    1.0.1   Common interface for HTTP messages
ratchet/pawl        v0.2.2  Asynchronous WebSocket client
ratchet/rfc6455     v0.2.1  RFC6455 WebSocket protocol handler
react/cache         v0.4.1  Async caching.
react/dns           v0.4.3  Async DNS resolver.
react/event-loop    v0.4.2  Event loop abstraction layer that libraries can use for evented I/O.
react/http          v0.4.1  Library for building an evented http server.
react/http-client   v0.4.10 Asynchronous HTTP client library.
react/promise       v2.4.1  A lightweight implementation of CommonJS Promises/A for PHP
react/socket        v0.4.3  Library for building an evented socket server.
react/socket-client v0.5.0  Async connector to open TCP/IP and SSL/TLS based connections.
react/stream        v0.4.3  Basic readable and writable stream interfaces that support piping.

@Akhawais
Copy link
Author

composer info showing the exact same versions as yours.

@mbonneau
Copy link
Member

What type of event loop is react using? You can find out like this:

<?php

require_once __DIR__ . '/vendor/autoload.php';

use React\EventLoop\Factory;

echo get_class(Factory::create()) . "\n";

@Akhawais
Copy link
Author

React\EventLoop\StreamSelectLoop

@mbonneau
Copy link
Member

That is what mine is using and should work fine. I am not sure what to try next - if you would like to post a packet capture of the attempted connection, I would be willing to look at it - or maybe someone else knows what is going on.

@Akhawais
Copy link
Author

Okay. What's really weird is the HTTP response that it outputs, I have no idea what server it's getting that from. Anyway, I'll try a bunch of things - maybe reinstalling Ratchet or trying a third machine - and if it still doesn't work then I'll do what you suggested.

Thanks for you help though. Appreciate it.

@Akhawais
Copy link
Author

Reinstalling Ratchet/3rd machine didn't work. Also tried a bare ratchet installation in a different directory which didn't work either.

@mbonneau Could you direct me on how to do a packet capture? If it helps, I've posted what seems like the HTTP response which gets outputted.

Thanks.

@Akhawais
Copy link
Author

If it helps, I'm using Google DNS and it still doesn't work.

On close event, I get this: Code: 1006 - Underlying connection closed

@Akhawais
Copy link
Author

Just a follow up on this:

I have setup a simple node.js websocket proxy on the same machine I am running Pawl with. Just relays the socket data between Pawl and the actual Ws server.

For some reason, this allows Pawl to connect to any websocket server (e.g. echo.socketo.me:9000 or echo.websocket.org) but using Pawl directly with those servers fails with 1006 - Underlying connection closed

Any ideas?

@cboden
Copy link
Member

cboden commented Aug 18, 2016

Very strange. Sounds like it could be some kind of firewall blocking? I ran your gist on a fresh install of Pawl and had no problems.

@Akhawais
Copy link
Author

I did try without any firewall running and that didn't work either.

I tried today connecting directly to the websocket server and it did successfully connect after 5 minutes of leaving it running. I don't believe that's caused by an issue with the particular server because the same delay occurs for echo.websocket.org.

The server in question (that I use Pawl mainly for) is irc-ws.chat.twitch.tv

I did notice that echo.socketo.me which is on port 9000 connects instantly however Twitch and websocket.org's echo are both on port 80.

That being said, I can still use a different client on the same machine to connect to Twitch instantly which is why I think it's Pawl and not a firewall (although this does look like a firewall issue)

I'll double check all my firewall rules and report back though.

Thanks for your time.

@Akhawais
Copy link
Author

Hey there, I found out that there was a function that was hanging in the then() closure. I've removed that and now Pawl is working fine.

Although I don't understand why it hangs in the test setup that I did, which doesn't have any functions in the closure.

Anyway, my issue is resolved with the main code. Thanks guys.

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

3 participants