Skip to content

Commit b8fe2a3

Browse files
committed
Ssl support
1 parent 17f1538 commit b8fe2a3

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

android/src/main/java/nl/kega/reactnativerabbitmq/RabbitMqConnection.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ public void initialize(ReadableMap config) {
6969
this.factory.setPort(this.config.getInt("port"));
7070
this.factory.setAutomaticRecoveryEnabled(true);
7171
this.factory.setRequestedHeartbeat(10);
72-
72+
73+
try {
74+
if (this.config.getInt("port") == 5671) {
75+
this.factory.useSslProtocol();
76+
}
77+
} catch(Exception e) {
78+
Log.e("RabbitMqConnection", e);
79+
}
7380

7481
}
7582

@@ -139,11 +146,11 @@ public void handleRecovery(Recoverable recoverable) {
139146
this.channel.addConfirmListener(new ConfirmListener() {
140147

141148
public void handleNack(long deliveryTag, boolean multiple) throws IOException {
142-
Log.e("RabbitMqQueue", "Not ack received -------------------------------");
149+
Log.e("RabbitMqQueue", "Not ack received");
143150
}
144151

145152
public void handleAck(long deliveryTag, boolean multiple) throws IOException {
146-
Log.e("RabbitMqQueue", "Ack received ------------------------------------");
153+
Log.e("RabbitMqQueue", "Ack received");
147154
}
148155
});
149156

ios/RCTReactNativeRabbitMq/RabbitMqConnection.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ @implementation RabbitMqConnection
2929
{
3030

3131
RabbitMqDelegateLogger *delegate = [[RabbitMqDelegateLogger alloc] initWithBridge:self.bridge];
32-
33-
NSString *uri = [NSString stringWithFormat:@"amqp://%@:%@@%@:%@/%@", self.config[@"username"], self.config[@"password"], self.config[@"host"], self.config[@"port"], self.config[@"virtualhost"]];
34-
//self.connection = [[RMQConnection alloc] initWithUri:uri verifyPeer:true delegate:delegate];
32+
33+
if(self.config[@"port"] == 5671) {
34+
NSString *uri = [NSString stringWithFormat:@"amqps://%@:%@@%@:%@/%@", self.config[@"username"], self.config[@"password"], self.config[@"host"], self.config[@"port"], self.config[@"virtualhost"]];
35+
} else {
36+
NSString *uri = [NSString stringWithFormat:@"amqp://%@:%@@%@:%@/%@", self.config[@"username"], self.config[@"password"], self.config[@"host"], self.config[@"port"], self.config[@"virtualhost"]];
37+
}
3538

3639
self.connection = [[RMQConnection alloc] initWithUri:uri
3740
channelMax:@65535

0 commit comments

Comments
 (0)