https self signed connect problem
Hi,
My problem is trying to connect to a self signed SSL URL with the following code using a custom path:-
NSURL* url = [[NSURL alloc] initWithString:@"https://test.com/chat"];
SocketIOClient *socket = [[SocketIOClient alloc] initWithSocketURL:url options:@{@"log":@YES, @"forcePolling":@YES, @"path":@"/testsocket/socket.io", @"selfSigned":@YES, @"sessionDelegate":self}];
[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
NSLog(@"socket connected");
}];
[socket connect];
The error I'm getting is
LOG SocketEngine: Got message: Cannot GET /socket.io?transport=polling&b64=1.
Does anyone know how to solve this issue? Without SSL it works fine and I also used the SessionDelegate. Basically the socket connected never gets fired. Thanks very much for the help.
Are you implementing the appropriate SessionDelegate method that handles SSL challenges?
hi,
This is what I did, is there something extra still needed? Thank you.
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler {
NSLog(@"test");
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
}
Is your URL the same for the non-ssl one? Just with https? Maybe your url is wrong.
the url is different but i'm suspecting it's with this I'm getting. I notice for successful connections sid is passing something over but for the failed connection sid is nil. Does the sid need to have something for it to connect successfully? Thank you very much for the help.
https://test.com/chatsocket/socket.io?transport=polling&b64=1&sid=
ok I have figured out the issue. What was happening is that the @"path":@"/testsocket/socket.io" parameter style for the ios library is different from the web version. The iOS needed an extra "/" at the end. So the error was because the end URL is incorrect. This is now resolved and thanks very much for the help!
I am using this library in obj-c project, everything was working great before I turned my server to https. At the moment I turned to https I was encountering invalid certificate issue which I had addressed by implementing didReceiveChallenge delegate method. Now, I am getting this error ;
Cannot GET /socket.io/?transport=polling&b64=1 socket = [[SocketIOClient alloc] initWithSocketURL:[[NSURL alloc] initWithString:@"https://localhost:xxxx"] config:@{@"log": @YES, @"forcePolling": @YES, @"selfSigned": @YES, @"sessionDelegate":appDelegate}];
I have also given a try by placing following key and value in config. @"path":@"/node_modules/socket.io"
Any prompt help will be really appreciated.
Thanks, I have resolved myself.
@githubforIT How did you resolve it? I am facing same issue. I appreciate if you can share your solution. Regards!