Answer the question
In order to leave comments, you need to log in
How to get rid of "POST net::ERR_CONNECTION_RESET" error?
I'm doing a php Ratchet chat and I'm having trouble with push notifications.
I'm sending a user message via ajax to send_message.php, and I'm getting an error: "POST work-fox/send_message.php net::ERR_CONNECTION_RESET".
chat.js:
var panel = document.querySelector('.panel');
var message = document.querySelector('.message');
var start_dialog = document.querySelector('#start_dialog');
var send_msg = document.querySelector('#send_msg');
var chatId = '1';
var conn = new ab.Session('ws://localhost:8443',
function() {
conn.subscribe(chatId, function(topic, data) {
// Сюда будут прилетать данные от вашего веб приложения.
console.log(data);
});
},
function() {
console.warn('Ошибка подключения к серверу ;)');
},
{'skipSubprotocolCheck': true}
);
send_msg.onclick = function(e) {
e.preventDefault();
var xhr = new XMLHttpRequest();
var form = new FormData();
form.append('message', message.value);
xhr.open("POST", "send_message.php", true);
xhr.send(form);
xhr.onload = function(e) {
console.log(this.responseText);
}
}
<?php
$entryData = array(
'fromId' => '1',
'message' => $_POST['message'],
'toId' => '2'
);
$context = new \ZMQContext();
$socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://localhost:5555");
$socket->send(json_encode($entryData));
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher')
Answer the question
In order to leave comments, you need to log in
Set the following OpenServer settings. Should earn.
As far as I know, Apache is there by default, ZMQ is not friendly with it for a number of reasons, judging by your question, it makes no sense to list them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question