File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -112,11 +112,13 @@ final class MQTTConnection {
112
112
default :
113
113
tlsConfiguration = TLSConfiguration . makeClientConfiguration ( )
114
114
}
115
- let sslContext = try NIOSSLContext ( configuration: tlsConfiguration)
116
- let tlsProvider = try NIOSSLClientTLSProvider < ClientBootstrap > ( context: sslContext, serverHostname: serverName)
117
- bootstrap = NIOClientTCPBootstrap ( clientBootstrap, tls: tlsProvider)
118
115
if client. configuration. useSSL {
116
+ let sslContext = try NIOSSLContext ( configuration: tlsConfiguration)
117
+ let tlsProvider = try NIOSSLClientTLSProvider < ClientBootstrap > ( context: sslContext, serverHostname: serverName)
118
+ bootstrap = NIOClientTCPBootstrap ( clientBootstrap, tls: tlsProvider)
119
119
return bootstrap. enableTLS ( )
120
+ } else {
121
+ bootstrap = NIOClientTCPBootstrap ( clientBootstrap, tls: NIOInsecureNoTLS ( ) )
120
122
}
121
123
return bootstrap
122
124
}
Original file line number Diff line number Diff line change @@ -384,6 +384,26 @@ final class MQTTNIOTests: XCTestCase {
384
384
try client. syncShutdownGracefully ( )
385
385
}
386
386
387
+ func testRawIPConnect( ) throws {
388
+ #if os(macOS)
389
+ if ProcessInfo . processInfo. environment [ " CI " ] != nil {
390
+ return
391
+ }
392
+ let elg = MultiThreadedEventLoopGroup ( numberOfThreads: 2 )
393
+ defer { XCTAssertNoThrow ( try elg. syncShutdownGracefully ( ) ) }
394
+ let client = MQTTClient (
395
+ host: " 127.0.0.1 " ,
396
+ identifier: " test/raw-ip " ,
397
+ eventLoopGroupProvider: . shared( elg) ,
398
+ logger: self . logger
399
+ )
400
+ _ = try client. connect ( ) . wait ( )
401
+ _ = try client. ping ( ) . wait ( )
402
+ try client. disconnect ( ) . wait ( )
403
+ try client. syncShutdownGracefully ( )
404
+ #endif
405
+ }
406
+
387
407
// MARK: Helper variables and functions
388
408
389
409
func createClient( identifier: String , configuration: MQTTClient . Configuration = . init( ) ) -> MQTTClient {
You can’t perform that action at this time.
0 commit comments