Anonymous Anonymous - 1 month ago
567 0

Fatal error: Uncaught ElephantIO\Exception\ServerConnectionFailureException: An error occurred while trying to establish a connection to the server in C:\xampp\htdocs\app\parent\chat\vendor\wisembly\elephant.io\src\Engine\SocketIO\Version1X.php:167 Stack trace: #0 C:\xampp\htdocs\app\parent\chat\vendor\wisembly\elephant.io\src\Engine\SocketIO\Version1X.php(48): ElephantIO\Engine\SocketIO\Version1X->handshake() #1 C:\xampp\htdocs\app\parent\chat\vendor\wisembly\elephant.io\src\Client.php(60): ElephantIO\Engine\SocketIO\Version1X->connect() #2 C:\xampp\htdocs\app\parent\chat\emit_test.php(11): ElephantIO\Client->initialize() #3 {main} thrown in C:\xampp\htdocs\app\parent\chat\vendor\wisembly\elephant.io\src\Engine\SocketIO\Version1X.php on line 167

Javascript

server.js

var socket = require('socket.io'),
	express = require('express'),
	https = require('https'),
	http = require('http'),
	logger = require('winston');

logger.remove(logger.transports.Console);
logger.add(logger.transports.Console, {colorize:true, timestamp:true});
logger.info('SocketIO listening on port');

var app = express();
var http_server = http.createServer(app).listen(process.env.PORT || 3000);

function emitNewOrder(http_server){
 var io=socket.listen(http_server);

 /*listen to the connection and call the callback*/
 io.sockets.on("connection", function(socket){

socket.on("new_order", function(data){
console.log(data);
});

 });
}
emitNewOrder(http_server);
PHP

emit_test.php

<?php
include("vendor/autoload.php");

use ElephantIO\Client;
use ElephantIO\Engine\SocketIO\Version1X;

$version= new Version1X('http://localhost:3000');

$client=new Client($version);

$client->initialize();
$client->emit("new_order", ["test"=>"test", "test1"=>"test1"]);
$client->close();
?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download