将Ratchet WsServer与React SecureServer结合使用(WSS/SSL)

我们正试图通过安全连接(WSS)实现websocket,并在我们的项目中实现了cboden/ratchet。所有Works正常连接罚款。环顾文档和Github项目页面,似乎新的React SecureServer类尚未在Ratchet中实现。将Ratchet WsServer与React SecureServer结合使用(WSS/SSL)

在我们发现的问题a post about it,它将不被支持,直到后来的版本,但是,我们现在需要它:D 在问题报告中,他们建议使用新的React SecureServer类与Ratchet类组合。我们尝试并得到了一个致命的错误:

Catchable fatal error: Argument 1 passed to React\Socket\SecureServer::__construct() must be an instance of React\Socket\Server, instance of Ratchet\Http\HttpServer given.

部分地方出了问题:

$webServer = new Ratchet\Server\IoServer(

new React\Socket\SecureServer(// Using React class here as suggested

new Ratchet\Http\HttpServer(

new Ratchet\WebSocket\WsServer(

new Ratchet\Wamp\WampServer(

$pusher

)

)

)

),

$webSock,

array(

'local_cert' => 'xxxx.pem',

'allow_self_signed' => true,

'verify_peer' => false

)

);

我们正在做一些愚蠢的事? :P

回答:

安全服务器应该围绕插座服务器要包装,而不是HTTP服务器:

$webServer = new Ratchet\Server\IoServer(

new Ratchet\Http\HttpServer(

new Ratchet\WebSocket\WsServer(

new Ratchet\Wamp\WampServer(

$pusher

)

)

)

),

new React\Socket\SecureServer(// Using React class here as suggested

$webSock,

$loop,

array(

'local_cert' => 'xxxx.pem',

'allow_self_signed' => true,

'verify_peer' => false

)

)

);

以上是 将Ratchet WsServer与React SecureServer结合使用(WSS/SSL) 的全部内容, 来源链接: utcz.com/qa/265529.html

回到顶部