Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@mrryanjohnston
Copy link

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
Copy link
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

@mrryanjohnston
Copy link
Author

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
Copy link
Member

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

@coderarity
Copy link
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
Copy link
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
Copy link
Member

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

@mrryanjohnston
Copy link
Author

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
Copy link
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
Copy link
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
Copy link
Author

@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
Copy link
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//issues/352#issuecomment-11867985.

Christian Howe (coderarity)

@mrryanjohnston
Copy link
Author

@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
Copy link

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
Copy link
Contributor

jcrugzz commented Oct 30, 2015

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

@jcrugzz jcrugzz closed this as completed Oct 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants