0
我使用pod RMQClient
和pod install
在我的項目中安裝RMQClient。然後我import <RMQClient/RMQClient.h>
在ViewController。 根據官方指導,我編寫了一些代碼,但是當我運行這個項目時,我得到握手超時錯誤。RMQClient(RabbitMQ)獲得握手超時錯誤
完全錯誤:
2017-10-17 11:32:06.960214+0800 RMQDemo[1637:557786] Received connection: <RMQConnection: 0x6080000ff780> disconnectedWithError: Error Domain=GCDAsyncSocketErrorDomain Code=8 "Error creating CFStreams" UserInfo={NSLocalizedDescription=Error creating CFStreams}
2017-10-17 11:32:06.963773+0800 RMQDemo[1637:557786] Received connection: <RMQConnection: 0x6000002e1500> disconnectedWithError: Error Domain=kCFStreamErrorDomainSSL Code=-9847 "(null)" UserInfo={NSLocalizedRecoverySuggestion=Error code definition can be found in Apple's SecureTransport.h}
2017-10-17 11:32:16.956467+0800 RMQDemo[1637:557769] Received connection: <RMQConnection: 0x6080000ff780> failedToConnectWithError: Error Domain=com.rabbitmq.rabbitmq-objc-client Code=1 "Handshake timed out." UserInfo={NSLocalizedDescription=Handshake timed out.}
2017-10-17 11:32:16.959851+0800 RMQDemo[1637:557769] Received connection: <RMQConnection: 0x6000002e1500> failedToConnectWithError: Error Domain=com.rabbitmq.rabbitmq-objc-client Code=1 "Handshake timed out." UserInfo={NSLocalizedDescription=Handshake timed out.}
我的代碼:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self send];
[self receive];
}
- (void)send
{
RMQConnection * conn = [[RMQConnection alloc] initWithUri:@"amqps://username:[email protected]:5672" delegate:[RMQConnectionDelegateLogger new]];
[conn start];
id<RMQChannel>channel = [conn createChannel];
RMQQueue * queue = [channel queue:@"hello"];
[channel.defaultExchange publish:[@"hello world" dataUsingEncoding:NSUTF8StringEncoding] routingKey:queue.name];
[conn close];
}
- (void)receive
{
RMQConnection * conn = [[RMQConnection alloc] initWithUri:@"amqps://username:[email protected]:5672" delegate:[RMQConnectionDelegateLogger new]];
[conn start];
id<RMQChannel>channel = [conn createChannel];
RMQQueue * queue = [channel queue:@"hello"];
[queue subscribe:^(RMQMessage * _Nonnull message) {
NSLog(@"message:%@",[[NSString alloc] initWithData:message.body encoding:NSUTF8StringEncoding]);
}];
[conn close];
}
如何解決這個問題呢?如何使用這個框架?
平臺:Xcode中9,iPhone8模擬器,iOS11
該服務正在運行。 – ttxoox