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

Getting "Connection closed before handshake" #48

Closed
quarkmarino opened this issue May 30, 2017 · 4 comments
Closed

Getting "Connection closed before handshake" #48

quarkmarino opened this issue May 30, 2017 · 4 comments

Comments

@quarkmarino
Copy link

quarkmarino commented May 30, 2017

Hi there, I'm having trouble connecting to the following ws "wss://streamer.cryptocompare.com"

docs here, https://www.cryptocompare.com/api/#-api-web-socket-

my implementation is the following

Btw, I'm running it on a laravel command "handle()' method

\Ratchet\Client\connect('wss://streamer.cryptocompare.com')->then(function($conn) {
	$conn->on('m', function($msg) use ($conn) {
		echo "Received: {$msg}\n";
		$conn->close();
	});


	$conn->send(['SubAdd' => '5~CCCAGG~BTC~USD']);
}, function ($e) {
	echo "Could not connect: {$e->getMessage()}\n";
});

basically the same first example from the docs, now, I've already got another working ws client in another project, however, in that other project I had to toy around with the headers, but this time, I haven't been able to make it work, also, I managed to implement this exact endpoint in nodejs using socket.io as a proof of concept, and it worked perfectly!, but really need to make it work on php

any idea, where it could be breaking, or where exactly to look at?

@mbonneau
Copy link
Member

@quarkmarino Can you post the node code for comparison?

@quarkmarino
Copy link
Author

quarkmarino commented May 30, 2017

@mbonneau Sure

in the same manner, it is an adonisJS command

'use strict'

const Command = use('Command')
const Io = use('socket.io-client')('https://streamer.cryptocompare.com/')

class CcMonitor extends Command {

  get signature () {
    return 'cc:monitor'
  }

  get description () {
    return 'Tell something helpful about this command'
  }

  * handle (args, options) {
    const subscription = ['5~CCCAGG~BTC~USD'];
    Io.emit('SubAdd', {subs:subscription} );
    Io.on('m', function(data){
      console.log(data)
    });
  }
}

module.exports = CcMonitor

and it totally works

@mbonneau
Copy link
Member

This is not working because Pawl does not implement the socket.io protocol that crytocompare is using. Pawl is only a websocket transport. socket.io is a protocol that runs on top of websockets (or other transports).

@quarkmarino
Copy link
Author

Ohh ok, then I'll have to go with socket.io, thank you for your time @mbonneau

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