Skip to content
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

HTTP GET Header #16

Open
jodm opened this issue Feb 25, 2014 · 14 comments
Open

HTTP GET Header #16

jodm opened this issue Feb 25, 2014 · 14 comments

Comments

@jodm
Copy link

jodm commented Feb 25, 2014

Hi.

I have an issue where I am trying to connect to a host with a path (i.e: http://www.url.com/path_1/path_2/websocket) and STOMPKit does not seem to support this.

What I was going to try and do is send a "GET: /path_1/path_2" http header in the method:

  • (void)connectWithHeaders:(NSDictionary *)headers
    completionHandler:(void (^)(STOMPFrame *connectedFrame, NSError *error))completionHandler;

The headers are a dictionary it that have to be key/value pairs, I need to send other headers like a token and a country but as you can see when I add my GET header like as the key and the value as blank (@{@"GET /path_1/path_2/websocket": @""} ) it does the following (predictably) although the GET header needs to NOT have the colon after it.
Token = 6d40c7d26a94c56b4b1ee001318bb7d7;
"GET /path_1/path_2/websocket" = "";
"CountryCode" = GB;

Is there any way I can modify StompKit to do this?

James

@jmesnil
Copy link
Contributor

jmesnil commented Feb 25, 2014

StompKit does not work over WebSocket. You should connect to the STOMP broker on its stomp port (usually 61613), not over a Web Socket on the 80 port.

@jodm
Copy link
Author

jodm commented Feb 25, 2014

Hi.

Thanks for the quick reply.

We are using STOMP over web sockets (Port 80). I can't seem to find any frameworks to support this? Is there any way of getting STOMPKit to work like this?

Can I do a standard web socket connection and pass this connection to StompKit?

The Javascript / Frontend guys are connecting to STOMPKit this:

(function () {
    var socket = new SockJS('http://www.url.com/path_1/stomp');
    var stompClient = Stomp.over(socket);

    stompClient.connect('', '', function (frame) {
        console.log('Connected ' + frame);

        stompClient.subscribe("/topic/1", function (message) {
            console.log(message.body);
        });
    }, function (error) {
        console.log("STOMP protocol error " + error);
    });
})();

Thanks
James

@jmesnil
Copy link
Contributor

jmesnil commented Feb 25, 2014

Like I said, StompKit can connect to the STOMP broker on a regular TCP port. Which broker are you using?

the stomp.js JavaScript library you are using is connecting over a Web Socket because you have no choice from a Web browser. But from an Objective-C client, there is no such restriction and you can connect to the TCP port directly.

@masgharneya
Copy link

@jodm StompKit is well written and won't require many changes to get your messages to go over websockets. You will need to replace GCDAsyncSocket with a web socket client. The only complete iOS one I know of is SocketRocket.

@jodm
Copy link
Author

jodm commented Mar 7, 2014

@masgharneya I finally got it working but thank you for your advise.

I used SocketRocket to do the websocket connection and then wrote my own STOMP message framework. For anyone interested I am planning on releasing this as a library:

https://github.com/jodm/SocketStompRocket

It will be uploaded by the end of March I just need to finish the iPhone application I am working on and I will extract it and make it standalone.

@Sumitkashid
Copy link

@jodm I want to know whether you have updated SocketStompRocket library on any other repository location? Because https://github.com/jodm/SocketStompRocket location do not have any other file except README.md file.

@gandhrekunal
Copy link

Hi @jodm , even I required SocketStompRocket library, can you please share repository location.

@jodm
Copy link
Author

jodm commented Jan 19, 2015

Hi. @Sumitkashid @gandhrekunal You know what it's like, best intensions to extract code from a project into a separate library and never get a chance.

I will try and find some time this week and extract it and update the SocketStompRocket repository.

Edit: One thing to note is I no longer have access to the Stomp / Socket Server so I won't be able to fully test but the code was working when the server was live.

Thanks
James.

@tbowers
Copy link

tbowers commented Apr 21, 2015

I have an outstanding pull request to integrate this functionality using RocketSockets. It seems to be working except the heartbeating (receiving PONG from my server) isn't working. I'm not sure which end is at fault yet.

@masgharneya
Copy link

@tbowers your PR will remove StompKit's ability to work over plain sockets. Might make more sense as a separate project.

@tbowers
Copy link

tbowers commented Apr 27, 2015

@masgharneya could you elaborate how? I specifically implemented the strategy pattern so that the existing raw socket usage would still work. If you init with a host that starts w/ "ws://", it'll use web sockets. If you init with host and port (i.e. existing API), the raw socket will be used.

@masgharneya
Copy link

@tbowers my mistake. I looked at one of the files you changed and saw that you removed a GCDAsyncSocket import so I assumed you removed it from the project. I should have looked further.

@lifeng198931
Copy link

Hi, I use stompkit to connect rabbitmq server , but i don't know how to use the vhost parameter,i want to know how to use the vhost parameter? thank you!

@buffpojken
Copy link

@lifeng198931 Your question has no relation to this issue at all, please open a new issue if
you have specific questions.

Otherwise - see https://www.rabbitmq.com/access-control.html for a discussion on vhosts (which also really has nothing to do with STOMP per se but is up to every specific broker to implement.

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

8 participants