mobile-web-messaging / StompKit

STOMP Objective-C Client for iOS
Apache License 2.0
95 stars 82 forks source link

Unable to connect to rabbitmq - can't set virtual host #18

Open ivan1986 opened 10 years ago

ivan1986 commented 10 years ago

https://github.com/mobile-web-messaging/StompKit/blob/master/StompKit/StompKit.m#L348 Set virtual host same as host, but by default virtualhost is / need add other option for virtualhost

jmesnil commented 10 years ago

you can pass it using the connectWithHeaders:completionHandler: method:

[self.client connectWithHeaders:@{@"virtualhost": @"/"}
              completionHandler:^(STOMPFrame *connectedFrame, NSError *error) {
                  ...
              }];
Fess200 commented 10 years ago

self.client = [[STOMPClient alloc] initWithHost:@"localhost" port:61613];

This return error -

[self.client connectWithHeaders:@{@"virtualhost": @"/",kHeaderLogin: @"guest", kHeaderPasscode: @"guest",kHeaderAcceptVersion:@"1.2", kHeaderHeartBeat: @"5000,10000",kHeaderHost:@"localhost"} completionHandler:^(STOMPFrame connectedFrame, NSError error) { ... }];

but if

[self.client connectWithHeaders:@{kHeaderLogin: @"guest", kHeaderPasscode: @"guest",kHeaderAcceptVersion:@"1.2", kHeaderHeartBeat: @"5000,10000",kHeaderHost:@"/"} completionHandler:^(STOMPFrame connectedFrame, NSError error) { ... }];

All is well

what am I doing wrong?

jmesnil commented 10 years ago

What is the error? What is RabbitMQ expecting to receive?

Have you read https://www.rabbitmq.com/stomp.html?

If a host header is specified it must be one of the virtual hosts known to the RabbitMQ server, otherwise the connection is rejected.

From what I understand, you don't need a virtualhost header at all.