我想要做的是運行聊天應用程序的PHP WebSocket服務器。 它在localhost上爲我工作,但是當我使用DNS將它上傳到域時,javascript不連接到服務器。從私人計算機發布php websocket服務器
server.php
<?php
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/So/Chat.php';
use So\Chat;
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
//What to write here?
$server = IoServer::factory(new HttpServer(new WsServer(new Chat)) 8080,'192.168.1.12');
$server->run();
?>
connection.js
function Connection(username, chatWindowId) {
this.username = username;
this.chatwindow = document.getElementById(chatWindowId);
this.open = false;
this.socket = new WebSocket("ws://5.29.101.176:80");//And here?
this.setupConnectionEvents();
}
你能後的PHP代碼,使我們能夠更好地理解你的問題? –
服務器的IP是否正確? – apokryfos
是的,你認爲問題是IP? – Adi1231234