-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't let client close the connection wait for server to initiate clo…
…se (#10) * Don't let client close the connection wait for server * Add timeout for close * Change Closing websocket debug to trace * Disable autobahn tests in CI
- Loading branch information
1 parent
e9763cf
commit 06e5e25
Showing
5 changed files
with
126 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Hummingbird server framework project | ||
// | ||
// Copyright (c) 2024 the Hummingbird authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Logging | ||
import NIOCore | ||
import NIOSSL | ||
import NIOWebSocket | ||
import WSClient | ||
import XCTest | ||
|
||
final class WebSocketClientTests: XCTestCase { | ||
|
||
func testEchoServer() async throws { | ||
let clientLogger = { | ||
var logger = Logger(label: "client") | ||
logger.logLevel = .trace | ||
return logger | ||
}() | ||
try await WebSocketClient.connect( | ||
url: "wss://echo.websocket.org/", | ||
tlsConfiguration: TLSConfiguration.makeClientConfiguration(), | ||
logger: clientLogger | ||
) { inbound, outbound, _ in | ||
var inboundIterator = inbound.messages(maxSize: .max).makeAsyncIterator() | ||
try await outbound.write(.text("hello")) | ||
if let msg = try await inboundIterator.next() { | ||
print(msg) | ||
} | ||
} | ||
} | ||
} |