FAQ
Hi,

I'm trying to create a chat application with login. I have manage to make
the chat and login work in a separate application but when integrating
them, they dont work.

I'm getting this error:

Failed to load resource: the server responded with a status of 404 (Not
Found) http://dev.nodejs.putoshop.com:3000/socket.io/socket.io.js
Uncaught ReferenceError: io is not defined dev.nodejs.putoshop.com/:14<http://dev.nodejs.putoshop.com:3000/>

I'm using EJS for my template engine. If I go to the port(3050) where the
chat application is listening, the chat application is working and when I
go to main port which is 3000, I can login but the chat application is not
working and showing the error above.

this is my EJS code:

<% if (!user) { %>
<h2>Welcome! Please log in.</h2>
<% } else { %>
<h2>Hello, <%= user.fullname %>.</h2>
<% } %>
<html>
<head>
<title>Putoshop Test Chat</title>
<!-- Include the socket.io javascript on the client side -->
<script> alert('test');</script>
<script src="socket.io/socket.io.js"></script>
<script> alert('test2');</script>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
// Establish the connection with the server
var socket = io.connect('http://dev.nodejs.putoshop.com:3050/');
// on every message recived we print the new datas inside the
#broadcast-msg div
socket.on('broadcast_msg', function (data) {
console.log('Get broadcasted msg:', data);
var msg = '<li>' + data + '</li>';
$('#broadcast-msg').append(msg);
});

// Create a new socket connection
socket.on('connect', function() {

// socket.emit('set nickname', prompt('What is your nickname?'));
socket.emit('User Name', prompt("What's your name...?"));

$('#msg-input').change( function(){
var txt = $(this).val();
$(this).val('');
socket.emit('emit_msg', txt, function (data){
console.log('Emit Broadcast msg', data);
});
});
});
</script>
</head>
<body>
<h1>PutoShop.com Test Nodejs Chat with login!</h1>
<label for="msg-input">Broadcast message</label>
<input id="msg-input" name="msg-input" type="text" size="30" />
<p>Press enter to submit your message</p>
<ul id="broadcast-msg"></ul>
</body>
</html>


Thanks,

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Ryan Schmidt at Jan 18, 2014 at 12:47 am

    On Jan 17, 2014, at 04:59, almarjin wrote:

    I'm trying to create a chat application with login. I have manage to make the chat and login work in a separate application but when integrating them, they dont work.

    I'm getting this error:

    Failed to load resource: the server responded with a status of 404 (Not Found) http://dev.nodejs.putoshop.com:3000/socket.io/socket.io.js
    Uncaught ReferenceError: io is not defined dev.nodejs.putoshop.com/:14

    I'm using EJS for my template engine. If I go to the port(3050) where the chat application is listening, the chat application is working and when I go to main port which is 3000, I can login but the chat application is not working and showing the error above.
    It sounds like in your server-side code you have forgotten to require('socket.io') and make it listen to your app. That’s what makes the path /socket.io/socket.io.js return the right script instead of the 404 error you’re getting.

    http://socket.io/#how-to-use


    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Almarjin at Feb 10, 2014 at 4:51 pm
    Hi ryan,

    Thanks for the reply, but the chat application if working properly which
    means the socket.io is defined properly in the server side code. In my
    above post it's listening to port 3050, but when I go to port 300, the chat
    is now working and I can login to the site. If I make them listed to the
    same port, I'm getting error.

    Thanks again
    On Saturday, January 18, 2014 8:46:52 AM UTC+8, ryandesign wrote:


    On Jan 17, 2014, at 04:59, almarjin <alma...@gmail.com <javascript:>>
    wrote:
    I'm trying to create a chat application with login. I have manage to
    make the chat and login work in a separate application but when integrating
    them, they dont work.
    I'm getting this error:

    Failed to load resource: the server responded with a status of 404 (Not
    Found) http://dev.nodejs.putoshop.com:3000/socket.io/socket.io.js
    Uncaught ReferenceError: io is not defined dev.nodejs.putoshop.com/:14

    I'm using EJS for my template engine. If I go to the port(3050) where
    the chat application is listening, the chat application is working and when
    I go to main port which is 3000, I can login but the chat application is
    not working and showing the error above.

    It sounds like in your server-side code you have forgotten to require('
    socket.io') and make it listen to your app. That’s what makes the path /
    socket.io/socket.io.js return the right script instead of the 404 error
    you’re getting.

    http://socket.io/#how-to-use

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ryan Schmidt at Feb 12, 2014 at 6:17 am
    I'm not sure what else to suggest. The error message is clear: your server is responding with a 404 not found error when the socket.io client-side JavaScript library is requested; therefore the io object is not defined on the client side. You'll need to figure out why your server is not responding to this request properly. Maybe find a simple example of using socket.io (like the ones on the socket.io homepage) and get it to work, then make small changes in the direction of what you want your app to do, and see if one particular change makes the problem appear.


    On Feb 10, 2014, at 10:51, almarjin wrote:

    Thanks for the reply, but the chat application if working properly which means the socket.io is defined properly in the server side code. In my above post it's listening to port 3050, but when I go to port 300, the chat is now working and I can login to the site. If I make them listed to the same port, I'm getting error.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Alexander Louizos Louizos at Jul 30, 2014 at 6:06 pm
    Hi,

    seems that you need to point to the route of your app like that

    script(type='text/javascript',
    scr='http://localhost:8080/socket.io/socket.io.js')

    where localhost:8080 use the port that you selected when building your app.


    On Friday, January 17, 2014 10:59:16 AM UTC, almarjin wrote:

    Hi,

    I'm trying to create a chat application with login. I have manage to make
    the chat and login work in a separate application but when integrating
    them, they dont work.

    I'm getting this error:

    Failed to load resource: the server responded with a status of 404 (Not
    Found) http://dev.nodejs.putoshop.com:3000/socket.io/socket.io.js
    Uncaught ReferenceError: io is not defined dev.nodejs.putoshop.com/:14
    <http://dev.nodejs.putoshop.com:3000/>

    I'm using EJS for my template engine. If I go to the port(3050) where the
    chat application is listening, the chat application is working and when I
    go to main port which is 3000, I can login but the chat application is not
    working and showing the error above.

    this is my EJS code:

    <% if (!user) { %>
    <h2>Welcome! Please log in.</h2>
    <% } else { %>
    <h2>Hello, <%= user.fullname %>.</h2>
    <% } %>
    <html>
    <head>
    <title>Putoshop Test Chat</title>
    <!-- Include the socket.io javascript on the client side -->
    <script> alert('test');</script>
    <script src="socket.io/socket.io.js"></script>
    <script> alert('test2');</script>
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script>
    // Establish the connection with the server
    var socket = io.connect('http://dev.nodejs.putoshop.com:3050/');
    // on every message recived we print the new datas inside the
    #broadcast-msg div
    socket.on('broadcast_msg', function (data) {
    console.log('Get broadcasted msg:', data);
    var msg = '<li>' + data + '</li>';
    $('#broadcast-msg').append(msg);
    });

    // Create a new socket connection
    socket.on('connect', function() {

    // socket.emit('set nickname', prompt('What is your nickname?'));
    socket.emit('User Name', prompt("What's your name...?"));

    $('#msg-input').change( function(){
    var txt = $(this).val();
    $(this).val('');
    socket.emit('emit_msg', txt, function (data){
    console.log('Emit Broadcast msg', data);
    });
    });
    });
    </script>
    </head>
    <body>
    <h1>PutoShop.com Test Nodejs Chat with login!</h1>
    <label for="msg-input">Broadcast message</label>
    <input id="msg-input" name="msg-input" type="text" size="30" />
    <p>Press enter to submit your message</p>
    <ul id="broadcast-msg"></ul>
    </body>
    </html>


    Thanks,
    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/9550f4f3-c9e3-477e-86ba-e2f0c19ad34b%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedJan 17, '14 at 10:59a
activeJul 30, '14 at 6:06p
posts5
users3
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase