1
我開發了PHP WebSocket服務器,它使用HTTP協議進行握手。一切正常。
當我想添加SSL層時,問題就開始了。當我啓用它HTTP幀到達時分成2塊 - 我需要調用讀取功能兩次以讀取第二片:PHP - 將SSL添加到TCP套接字時出現意外的行爲
- HTTP標頭的第一個字母(G)
- 頭
沒有SSL一切正常。我嘗試了很多修改但沒有結果。 任何想法?
上市讀功能:
protected function read($toRead = 1400) { $return = ""; for (;;) { if ($toRead < Config::$socket['chunk_size']) { $length = $toRead; } else { $length = Config::$socket['chunk_size']; } $sData = fread($this->socket, $length); if ($sData == false) return false; $toRead = $toRead - $length; $return .= $sData; if ($toRead == 0) break; } var_dump($return); return $return; }
的SSLContext:
protected function createSSLContext() {
$context = stream_context_create();
if (Config::$ssl['switch']) {
stream_context_set_option($context, 'ssl', 'local_cert', Config::$ssl['filename']);
stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
stream_context_set_option($context, 'ssl', 'verify_peer', false);
if (isset(Config::$ssl['passphrase'])) {
stream_context_set_option($context, 'ssl', 'passphrase', Config::$ssl['passphrase']);
}
}
$this->context = $context;
}
顯示沒有錯誤? – Raptor
沒有,沒有 – Adam
沒有啓用「顯示錯誤」? – Raptor