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

What is the best way to send single message and read reply #98

Open
khvalov opened this issue Aug 5, 2019 · 1 comment
Open

What is the best way to send single message and read reply #98

khvalov opened this issue Aug 5, 2019 · 1 comment
Labels

Comments

@khvalov
Copy link

khvalov commented Aug 5, 2019

Hi,
I'm interacting with Websocket server and the first step I have to implement is - authorize with sending websocket JSON packet. And I'm expecting answer contain Client ID some other connection related data
The problem I have experienced with - as all I send is combined into frames (?) the authorization request get sent only withing next iteraction backages and I got "not authorized" response.

The way I use Pawl (simplified)

$connector('ws://webserver/connection/websocket')
			->then(function(\Ratchet\Client\WebSocket $conn) {
			
			$this->authenticate($conn);
			$this->subscribe($channelID);

			//Default behavior on connection close
	        $conn->on('close', function($code = null, $reason = null) {
	        	$this->runEvents(self::EVENT_DISCONNECTED,[$code=>$reason]);
	            $this->loop->stop();
	        });

	        //Handling messages
	        $conn->on('message', function(\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
	            $this->messageHandler(strval($msg));
	        });
	    }, function(\Exception $e){
	        echo "Could not connect: {$e->getMessage()}\n";
	        $this->loop->stop();
	    });

		$this->loop->run();
	}

is any way to enforce send ws request ?

@ced1check
Copy link

It's been quite some time, however did you find a solution for this? I have a similar issue where I need to send an init message, get the ack and then send a subscribe, however I never catch the ack reply. the on('message') handler never gets called for some odd reason!?

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

No branches or pull requests

3 participants