socket.io connection on same origin, but different port

2,681 views
Skip to first unread message

Kai

unread,
Jul 28, 2011, 12:08:01 PM7/28/11
to Socket.IO
Hi!

I am sure that my question has been answered several times, but I
didn't find any valuable answers. I am running an application on
http://localhost:4444 and want to connect to my socket.io server
running at http://localhost:8888 . The following code works fine when
I am on the same domain/ port, but not from port 4444:

var conn = io.connect("http://localhost:8888");
conn.on("connect", function(){alert("Connect")});

I am not sure if the same origin policies are valid here, why isn't
the connection successful?

Thank you for answering this stupid question!

Kai

unread,
Aug 5, 2011, 11:41:02 AM8/5/11
to Socket.IO
I can't imagine that nobody had tried to access a socketio-server from
another port? No hint for me what I am doing wrong?

On 28 Jul., 18:08, Kai <schlichting....@googlemail.com> wrote:
> Hi!
>
> I am sure that my question has been answered several times, but I
> didn't find any valuable answers. I am running an application onhttp://localhost:4444and want to connect to my socket.io server
> running athttp://localhost:8888. The following code works fine when

Arnout Kazemier

unread,
Aug 5, 2011, 12:37:24 PM8/5/11
to sock...@googlegroups.com
Well our complete test-runner runs cross port, so `we` got it working here, so I wonder what your setup it

Daniel Shaw

unread,
Aug 5, 2011, 2:34:10 PM8/5/11
to sock...@googlegroups.com
Yeah, definitely not an issue. Check to make sure you're loading the
client-side libraries and double check your setup.
What does http://localhost:8888/socket.io/socket.io.js report?

Daniel Shaw
@dshaw

Kai

unread,
Aug 7, 2011, 4:53:42 AM8/7/11
to Socket.IO
I could break down the problem to a simple test page, it must have to
do something with XHTML vs HTML. When I save https://gist.github.com/15fc854708f97cb9323e
in test.html and test.xhtml and call them via http://localhost:4444/test.(html|xhtml),
the file ending with xhtml doesn't alert the expected output. I won't
be able to switch to HTML, so do you have any idea what could cause
this issue?



On 5 Aug., 20:34, Daniel Shaw <ds...@dshaw.com> wrote:
> Yeah, definitely not an issue. Check to make sure you're loading the
> client-side libraries and double check your setup.
> What doeshttp://localhost:8888/socket.io/socket.io.jsreport?
>
> Daniel Shaw
> @dshaw
>
>
>
>
>
>
>
> On Thu, Jul 28, 2011 at 9:08 AM, Kai <schlichting....@googlemail.com> wrote:
> > Hi!
>
> > I am sure that my question has been answered several times, but I
> > didn't find any valuable answers. I am running an application on
> >http://localhost:4444and want to connect to my socket.io server
> > running athttp://localhost:8888. The following code works fine when

Kai

unread,
Aug 10, 2011, 4:17:47 PM8/10/11
to Socket.IO
Weird, I think I found the issue. I changed line 1539 in /socket.io/
socket.io.js :

- , script = document.createElement('SCRIPT');
+ , script = document.createElement('script');

When creating a script-Tag instead of a SCRIPT-Tag all works fine! I
am not sure if this is a bug or if I am doing something wrong - any
opinions?

On 7 Aug., 10:53, Kai <schlichting....@googlemail.com> wrote:
> I could break down the problem to a simple test page, it must have to
> do something with XHTML vs HTML. When I savehttps://gist.github.com/15fc854708f97cb9323e
> in test.html and test.xhtml and call them viahttp://localhost:4444/test.(html|xhtml),
> the file ending with xhtml doesn't alert the expected output. I won't
> be able to switch to HTML, so do you have any idea what could cause
> this issue?
>
> On 5 Aug., 20:34, Daniel Shaw <ds...@dshaw.com> wrote:
>
>
>
>
>
>
>
> > Yeah, definitely not an issue. Check to make sure you're loading the
> > client-side libraries and double check your setup.
> > What doeshttp://localhost:8888/socket.io/socket.io.jsreport?
>
> > Daniel Shaw
> > @dshaw
>
> > On Thu, Jul 28, 2011 at 9:08 AM, Kai <schlichting....@googlemail.com> wrote:
> > > Hi!
>
> > > I am sure that my question has been answered several times, but I
> > > didn't find any valuable answers. I am running an application on
> > >http://localhost:4444andwant to connect to my socket.io server

Roman Land

unread,
Aug 11, 2011, 1:23:58 PM8/11/11
to sock...@googlegroups.com
sounds like an IE issue...
--
---
"Make everything as simple as possible, but not simpler."

- Albert Einstein

Jesse Degger

unread,
Aug 11, 2011, 1:33:11 PM8/11/11
to Socket.IO
Since HTML must be lowercase, this isn't a real issue.
> > > >http://localhost:4444andwantto connect to my socket.io server

Kai Schlichting

unread,
Aug 11, 2011, 3:06:55 PM8/11/11
to sock...@googlegroups.com
The issue is reproducable in Firefox, Safari and Chrome (I am not
working with IE). I think the answer is: XHTML is based on XML, and
therefore element names are case sensitive and have to be lower case
(http://www.w3.org/TR/xhtml1/#h-4.2).

So this seems to be a real issue, I created a ticket:
https://github.com/LearnBoost/socket.io/issues/460

2011/8/11 Jesse Degger <deg...@live.nl>:

Reply all
Reply to author
Forward
0 new messages