samedi 18 avril 2015

Issue in connecting Rails client to Node server

I have a chat application on Nodejs+Socket.io which is running on http://localhost:5001 and the other hand there is a rails application which is running on http://localhost:3000


What i want to achieve ?



  1. Connect rails client to node server to talk to each other.


What i did ?


Node server working properly


Added in rails chat page.



<ul id="messages"></ul>

<form action="">
<input id="m" autocomplete="off"/>
<button>Send</button>
</form>
<script src="http://localhost:5001/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost:5001');
socket.on('connect', function (data) {
console.log('connected!');
});
</script>
<script>
var socket = io();
$('form').submit(function () {
socket.emit('chat message', $('#m').val());
$('#m').val('');
return false;
});

socket.on('chat message', function (msg) {
$('#messages').append($('<li>').text(msg));
});
</script>


What is the issue ?


The moment i am loading the page it is showing connected (connected to Node server side also) but just after the first page load port becomes 5001 to 3000 and obviously 404 for socket.io.


enter image description here


Aucun commentaire:

Enregistrer un commentaire