Skip to content
This repository has been archived by the owner on Mar 6, 2018. It is now read-only.

Connecting with query parameters #24

Closed
peenuty opened this issue Aug 26, 2012 · 8 comments
Closed

Connecting with query parameters #24

peenuty opened this issue Aug 26, 2012 · 8 comments

Comments

@peenuty
Copy link

peenuty commented Aug 26, 2012

Hi,

I had problems using your api when the url I needed to connect to had ?key=val

I am currently just trying to get a project working in my spare time so I have take your source into my project and fixed it. But my fix is pretty crude and might not working all cases.

The crux of the fix is in the handshake() method in IOConnection, to do something like this:

        URL origin = getOrigin();
        if (IOConnection.this.url.getQuery() != null && IOConnection.this.url.getQuery() != "") {
            url = new URL(origin.toString() + SOCKET_IO_1 + "?" + IOConnection.this.url.getQuery());
        } else {
            url = new URL(origin.toString() + SOCKET_IO_1);
        }

When you set the url field in IOConnection you only set the origin (there might be a good reason for this...!). Instead I changed it to set the full URL and then wrote a getOrigin method which I called in the right places.

private URL getOrigin() throws MalformedURLException {
    return new URL(IOConnection.this.url.getProtocol() + "://" + IOConnection.this.url.getHost());
}

This seems to work, apologies if I have misunderstood your api, thanks for writing it though :)

Rich

@Gottox
Copy link
Owner

Gottox commented Aug 28, 2012

Hi @peenuty !

Thanks for pointing this out. socket.io doesn't handle query strings very well. The problem about your approach is, that an IOConnection can be multiplexed. That means, different SocketIO instances can use the same IOConnection. If you send different query strings over a multiplexed connection, only the first one gets sent to the server.

Actually, this buggy approach is the way it is done in @LearnBoost socket.io implementation. So, I consider following this. But I suspect that this leads to nasty bugs.

Enno

PS: There's a bugreport for this issue with an apt title: socketio/socket.io-client#331

@Gottox
Copy link
Owner

Gottox commented Oct 1, 2012

The issue is still open, but it's a protocol issue, not a socket.io-java-client specific one. I'm hoping for protocol revision 1.0 to fix this issue.

For now, query strings are not supported by socket.io-java-client.

@Gottox Gottox closed this as completed Oct 1, 2012
@YongGang
Copy link

socket.io support connect with querystring since 0.9.6, socketio/socket.io-client#467
Could you please fix the java client?

@cendrizzi
Copy link

This would be really nice. Other than this single feature everything is working great with this client.

@fatshotty
Copy link
Contributor

any news?

@fatshotty
Copy link
Contributor

I have pushed the query string integration in my fork but I cannot send pull-request.
I will ping @Gottox soon

here is my commit: fatshotty@bf08624#commitcomment-3446681

@fatshotty
Copy link
Contributor

version 0.2.1 has been deployed on maven repo.
It contains all changes and also this issue fixed

@sanakanchha
Copy link

Hello fatshotty,
great that your fork has the maven dependency and querystrings support. Because maven would be way easier for me to implement. A quick question: Does your fork 0.2.1 include everything thats on Gottox/socket.io-java-client?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants