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

Closed
mrryanjohnston opened this Issue Dec 18, 2012 · 14 comments

Projects

None yet

5 participants

@mrryanjohnston

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

@indexzero
Member

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

@indexzero indexzero closed this Dec 19, 2012
@mrryanjohnston

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.

@indexzero indexzero reopened this Dec 19, 2012
@indexzero
Member

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

@coderarity
Contributor

@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. 😆

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

@coderarity
Contributor

@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.

@indexzero
Member

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

@mrryanjohnston

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);

@indexzero
Member

@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.

@coderarity
Contributor

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

@mrryanjohnston

@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.
@coderarity
Contributor

How are you connecting to socket.io? I think that might be where the
problem is from here.

About #1, that's part of fixing the proxy table issues.

On Thursday, January 3, 2013, Ryan Johnston wrote:

@coderarity https://github.com/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.


Reply to this email directly or view it on GitHubhttps://github.com/nodejitsu/node-http-proxy/issues/352#issuecomment-11867985.

Christian Howe (coderarity)

@mrryanjohnston

@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.

@marcilioleite

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>
@jcrugzz
Member
jcrugzz commented Oct 30, 2015

Closing due to old age and related to old version of http-proxy

@jcrugzz jcrugzz closed this Oct 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment