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 {
112112 default :
113113 tlsConfiguration = TLSConfiguration . makeClientConfiguration ( )
114114 }
115- let sslContext = try NIOSSLContext ( configuration: tlsConfiguration)
116- let tlsProvider = try NIOSSLClientTLSProvider < ClientBootstrap > ( context: sslContext, serverHostname: serverName)
117- bootstrap = NIOClientTCPBootstrap ( clientBootstrap, tls: tlsProvider)
118115 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)
119119 return bootstrap. enableTLS ( )
120+ } else {
121+ bootstrap = NIOClientTCPBootstrap ( clientBootstrap, tls: NIOInsecureNoTLS ( ) )
120122 }
121123 return bootstrap
122124 }
Original file line number Diff line number Diff line change @@ -384,6 +384,26 @@ final class MQTTNIOTests: XCTestCase {
384384 try client. syncShutdownGracefully ( )
385385 }
386386
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+
387407 // MARK: Helper variables and functions
388408
389409 func createClient( identifier: String , configuration: MQTTClient . Configuration = . init( ) ) -> MQTTClient {
You can’t perform that action at this time.
0 commit comments