

رفع مشکل WHM دسترسی پروتکل (443) و (8080)
- توسعه نرمافزار و آیتی
سلام
ما برای فعال سازی چت آنلاین ، کتابخانه (Ratchet) وب سوکت (WebSocket) در سی پنل آپاچی نصب کردیم .
و می بایستی دسترسی پروتکل (443) و (8080) داشته باشیم . اما متاسفانه خطای :
WebSocket connection to 'wss://mywebsite.com:8080/' failed.
1- ما نیاز داریم این مشکل یعنی عدم دسترسی حل شود.
2- دسترسی پورت های فوق را خارج از سایت یعنی خارج از دامنه مربوط مسدود کنیم.
نمونه کد server.php <?php require 'vendor/autoload.php'; // Load Autoload
use Ratchet\MessageComponentInterface; use Ratchet\ConnectionInterface; use Ratchet\Http\HttpServer; use Ratchet\Server\IoServer; use Ratchet\WebSocket\WsServer;
class Chat implements MessageComponentInterface { protected $clients;
public function __construct() {
$this->clients = new \SplObjectStorage; // Store all active connections
}
public function onOpen(ConnectionInterface $conn) {
// Store the new connection
$this->clients->attach($conn);
}
public function onMessage(ConnectionInterface $from, $msg) {
foreach ($this->clients as $client) {
// Don't send the message to the sender
if ($from !== $client) {
$client->send($msg);
}
}
}
public function onClose(ConnectionInterface $conn) {
// Detach the connection
$this->clients->detach($conn);
}
public function onError(ConnectionInterface $conn, \Exception $e) {
$conn->close();
}}
$server = Ratchet\server\IoServer::factory( new Ratchet\Http\HttpServer( new Ratchet\ConnectionInterface(new Chat()) ), 8080 // Choose a port ); $server->run();
نمونه کد چت chat.php :
<title><style>Chat Room
<script> var conn = new WebSocket('wss://mywebsite.com:8080'); conn.onmessage = function(e) {
var messagesDiv = document.getElementById('messages');
messagesDiv.innerHTML += '<div>' + e.data + '</div>';
messagesDiv.scrollTop = messagesDiv.scrollHeight;
};
document.getElementById('input').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
conn.send(this.value);
this.value = '';
}
});
</script>مهارتهای مورد نیاز
آپاچی (Apache)
Linux
راه اندازی سرور لینوکس
Web Hosting
امکانات ویژه
فوری
برجسته
سرویسهای مرتبط
فریلنسرهایی که در این پروژه پیشنهاد ارسال کردهاند
- کارفرما این پیشنهاد را انتخاب کرده است.
joodev4.78(9) امتیاززمان تحویل: 1 روزارسال پیشنهاد در: - زمان تحویل: 1 روزارسال پیشنهاد در:
- CHزمان تحویل: 5 روزارسال پیشنهاد در: