Skip to content

Commit fad687a

Browse files
committed
server: fix Wss protocol error - use ws:// with transport=ssl
AsyncTcpConnection doesn't have a Wss protocol class. Workerman's Ws protocol handles SSL via context options with transport=ssl, not via the wss:// scheme. Changed buildHubRelayWsUrl() to always return ws:// and openHubConnection() to set transport=>'ssl' in context.
1 parent 380c888 commit fad687a

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/Hub/RelayConfig.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ public function buildHubRelayWsUrl(): string
182182
return '';
183183
}
184184

185-
$scheme = (isset($parts['scheme']) && $parts['scheme'] === 'wss') ? 'wss' : 'ws';
186-
187-
return $scheme . '://' . $parts['host'] . ':' . self::DEFAULT_HUB_RELAY_WS_PORT;
185+
// Always use ws://; SSL is handled via context options in openHubConnection(),
186+
// not via the wss:// scheme (Workerman's AsyncTcpConnection doesn't have a Wss protocol class).
187+
return 'ws://' . $parts['host'] . ':' . self::DEFAULT_HUB_RELAY_WS_PORT;
188188
}
189189

190190
/**

src/Hub/RelayConsumer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ private function openHubConnection(string $wsUrl): AsyncTcpConnection
321321
'verify_peer' => true,
322322
'SNI_enabled' => true,
323323
],
324+
'transport' => 'ssl',
324325
];
325326

326327
return new AsyncTcpConnection($wsUrl, $context);

0 commit comments

Comments
 (0)