Skip to content
This repository

`Cannot GET //socket.io/socket.io.js` when using Express, Socket.io and node-http-proxy #352

Open
mrryanjohnston opened this Issue · 13 comments

4 participants

Ryan Johnston Charlie Robbins Christian Howe Marcilio Leite
Ryan Johnston

The following gist produces a socket.io/socket.io.js 404 (Not Found) error on the browser's side:
https://gist.github.com/4324446

This gist does not reproduce that error:
https://gist.github.com/4324576

Charlie Robbins
Owner

This has nothing to do with node-http-proxy. The /test/ prefix in your html file is wrong: https://gist.github.com/4324446#file-gistfile1-html-L1

Ryan Johnston

Actually, that's what is currently written in the index.html file. I thought I'd revised that gist to the current implementation, but I guess not. This bug was confirmed in the #nodejitsu channel a few nights ago.

Charlie Robbins
Owner

Try it without the router. Just do a straight proxy.

Christian Howe

@mrryanjohnston What version of node-http-proxy are you using? I think I may have saw something from an old version and gotten confused. Or maybe I was really too tired that night, I was sure I saw a "/" + somewhere. That wouldn't be the first mistake I realized I made that night. :laughing:

In any case, if you want to come into #nodejitsu again we can try to debug it some more.

Christian Howe

@mrryanjohnston I think I know the problem. Try using 'dev.example.com/test/' in the proxy table.

@indexzero The test prefix makes sense. He's requesting the 'dev.example.com/test' thing, so if he doesn't use the '/test/' prefix, it won't route to that express server, thereby not finding that path. The fact that he got that express error shows that it's connecting to the express server, like he wants. It's just due to the way I wrote the URL replacement code. I think we can fix this by adding a '/' at the end of the origin URL if the user didn't add it, or removing the first '/' in the request URL, and adding it back in if it's not there at the end of that transformation process. I think the latter is a better idea.

Charlie Robbins
Owner

@mrryanjohnston Can you please try it without the router option when calling httpProxy.createServer()?

Ryan Johnston

Sorry about the delay on this one, guys. Holidays and whatnot :)

@coderarity package.json says "version": "0.8.5". I did try using dev.example.com/test in the routing table, but to no avail. I'll pop back in irc when I'm back from holiday related festivities. Thank you for your patience, once again.

@indexzero If I change the line to the following, the socket.io script is placed at localhost:8080/socket.io/socket.io.js as expected: var proxyServer = httpProxy.createServer(9000, 'localhost').listen(8080);

Charlie Robbins
Owner

@mrryanjohnston I suspect this is related to the ProxyTable somewhere. I'll leave this open to investigate, but I won't lie the ProxyTable is not high on my list of priorities.

Christian Howe

@mrryanjohnston Heh, that's not the URL I suggested, yo. You've got to use "dev.example.com/test/" (note the ending /). :D

Ryan Johnston

@coderarity So this does two things:
1. You can no longer go to dev.example.com/test in a browser window; only dev.example.com/test/ will work.
2. This produces an error that seems to be on part of socket.io: GET http://dev.example.com/socket.io/1/?t=1357260316641 404 (Not Found). This occurs in socket.io.js on line 1659. Correct me if I'm wrong, but this seems to be an error on part of socket.io.

Christian Howe
Ryan Johnston

@coderarity Sorry for the delay on this. Haven't had a chance for fun side-projects for a while :)

I'm currently connecting with an absolute link: var socket = io.connect('http://dev.example.com/test/');

I understand it's not a super high-priority thing for this project. All the same, thanks for all of your help on this.

Marcilio Leite

Hi, i had the same issue and solved it:

socket = io.connect('http://192.168.1.101:8000');
<script src="http://192.168.1.101:8000/socket.io/socket.io.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.