not working in xcode 12
DiamondYuan opened this issue · comments
//
// ContentView.swift
// mirror
//
// Created by DiamondYuan on 2020/10/31.
//
import SwiftUI
import Telegraph
struct ContentView: View {
var body: some View {
Button(action: {
let serverHTTP = Server()
serverHTTP.route(.GET, "status") { (.ok, "Server is running") }
try! serverHTTP.start(port: 9000,interface: "localhost")
print("[SERVER]", "Server is running - url:", serverHTTP.isRunning)
}, label: {
Text("Start")
})
Button(action: {
let url = URL(string: "http://localhost:9000/status")!
let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
guard let data = data else { return }
print(String(data: data, encoding: .utf8)!)
}
task.resume()
}, label: {
/*@START_MENU_TOKEN@*/Text("Button")/*@END_MENU_TOKEN@*/
})
Text("Hello, world!")
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
[SERVER] Server is running - url: true
2020-10-31 10:35:05.097959+0800 mirror[50805:6813940] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
2020-10-31 10:35:05.098564+0800 mirror[50805:6813940] [connection] nw_socket_handle_socket_event [C1.1.1:2] Socket SO_ERROR [61: Connection refused]
2020-10-31 10:35:05.099988+0800 mirror[50805:6813940] [connection] nw_socket_handle_socket_event [C1.1.2:2] Socket SO_ERROR [61: Connection refused]
2020-10-31 10:35:05.101072+0800 mirror[50805:6813940] Connection 1: received failure notification
2020-10-31 10:35:05.101202+0800 mirror[50805:6813940] Connection 1: failed to connect 1:61, reason -1
2020-10-31 10:35:05.101317+0800 mirror[50805:6813940] Connection 1: encountered error(1:61)
2020-10-31 10:35:05.103321+0800 mirror[50805:6813940] Task .<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
2020-10-31 10:35:05.106915+0800 mirror[50805:6813940] Task .<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x6000025357a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask .<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=http://localhost:9000/status, NSErrorFailingURLKey=http://localhost:9000/status, _kCFStreamErrorDomainKey=1}
Did you ever solve this? Same issue.