Giter Site home page Giter Site logo

perfectlysoft / perfect-net Goto Github PK

View Code? Open in Web Editor NEW
27.0 8.0 29.0 137 KB

Core asynchronous networking package used in Perfect. Includes support for TCP, SSL, UNIX socket files and IO event handling.

Home Page: www.perfect.org

License: Apache License 2.0

Swift 100.00%
swift tcp ssl server-side-swift unix-socket-files perfect

perfect-net's Introduction

Perfect-Net

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 4.1 Platforms OS X | Linux License Apache PerfectlySoft Twitter Slack Status

Core asynchronous networking package used in Perfect. Includes support for TCP, SSL, UNIX socket files and IO event handling.

Further Information

For more information on the Perfect project, please visit perfect.org.

perfect-net's People

Contributors

chrishulbert avatar iamjono avatar kjessup avatar krissimon avatar mczachurski avatar mlilback avatar rodrigue-h avatar yegortokmakov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

perfect-net's Issues

TCPSSL.close() crashing the server on Docker behind nginx proxy

I have a very weird situation with docker/nginx and websockets, I proxy through nginx to a websocket server(Perfect-Websocket) and every time i close the connection the server crashes.

If i connect directly to the websocket server and close the connection its all fine.

If I run the websocket server through Xcode and nginx to that and close the connection it all works fine too.

I have check all the linux dependancies and none of them have been upgraded since Sept 2019 (only started to happen last night)

Commands to cause

var s = new WebSocket("wss://localhost:8080/socket", "zara")
s.close();

Crash Dump Log

zaraapp_1  | * thread #7, name = 'issueServer', stop reason = signal SIGPIPE
zaraapp_1  |     frame #0: 0x00007ffff76832b7 libpthread.so.0`__libc_write + 71

Full Error Message

zaraapp_1  | * thread #8, name = 'issueServer', stop reason = signal SIGPIPE
zaraapp_1  |   * frame #0: 0x00007ffff76832b7 libpthread.so.0`__libc_write + 71
zaraapp_1  |     frame #1: 0x00007ffff5a48be5 libcrypto.so.1.1`___lldb_unnamed_symbol314$$libcrypto.so.1.1 + 37
zaraapp_1  |     frame #2: 0x00007ffff5a43f7a libcrypto.so.1.1`___lldb_unnamed_symbol239$$libcrypto.so.1.1 + 26
zaraapp_1  |     frame #3: 0x00007ffff5a42fd5 libcrypto.so.1.1`___lldb_unnamed_symbol236$$libcrypto.so.1.1 + 133
zaraapp_1  |     frame #4: 0x00007ffff5a43473 libcrypto.so.1.1`BIO_write + 35
zaraapp_1  |     frame #5: 0x00007ffff5e84cb7 libssl.so.1.1`___lldb_unnamed_symbol113$$libssl.so.1.1 + 151
zaraapp_1  |     frame #6: 0x00007ffff5e85bd5 libssl.so.1.1`___lldb_unnamed_symbol114$$libssl.so.1.1 + 3557
zaraapp_1  |     frame #7: 0x00007ffff5e8f6cc libssl.so.1.1`___lldb_unnamed_symbol201$$libssl.so.1.1 + 92
zaraapp_1  |     frame #8: 0x00007ffff5e8d7a5 libssl.so.1.1`___lldb_unnamed_symbol182$$libssl.so.1.1 + 197
zaraapp_1  |     frame #9: 0x00007ffff5e986bf libssl.so.1.1`SSL_shutdown + 63
zaraapp_1  |     frame #10: 0x0000555555c31ee0 issueServer`NetTCPSSL.close(self=<unavailable>) at NetTCPSSL.swift:355:4 [opt]
zaraapp_1  |     frame #11: 0x0000555555c8a6ae issueServer`partial apply for closure #1 in WebSocket.close() [inlined] closure #1 (self=<unavailable>) -> () in PerfectWebSockets.WebSocket.close() -> () at WebSocketHandler.swift:87:17 [opt]
zaraapp_1  |     frame #12: 0x0000555555c8a694 issueServer`partial apply for closure #1 in WebSocket.close() at <compiler-generated>:0 [opt]
zaraapp_1  |     frame #13: 0x0000555555c90a29 issueServer`partial apply for closure #1 in WebSocket.sendMessage(opcode:bytes:final:completion:) [inlined] closure #1 (completion=0x0000000000000000) -> () in PerfectWebSockets.WebSocket.(sendMessage in _0CBBC1EF67015CC10ED91AFD31C801C6)(opcode: PerfectWebSockets.WebSocket.OpcodeType, bytes: Swift.Array<Swift.UInt8>, final: Swift.Bool, completion: () -> ()) -> () at WebSocketHandler.swift:261:4 [opt]
zaraapp_1  |     frame #14: 0x0000555555c90a1f issueServer`partial apply for closure #1 in WebSocket.sendMessage(opcode:bytes:final:completion:) at <compiler-generated>:0 [opt]
zaraapp_1  |     frame #15: 0x0000555555c2d0be issueServer`NetTCP.write(bytes:completion:) at NetTCP.swift:0 [opt]
zaraapp_1  |     frame #16: 0x0000555555c2cfcf issueServer`NetTCP.write(byts=2 values, completion=0x0000555555c90a10 issueServer`partial apply forwarder for closure #1 (Swift.Int) -> () in PerfectWebSockets.WebSocket.(sendMessage in _0CBBC1EF67015CC10ED91AFD31C801C6)(opcode: PerfectWebSockets.WebSocket.OpcodeType, bytes: Swift.Array<Swift.UInt8>, final: Swift.Bool, completion: () -> ()) -> () at <compiler-generated>, self=<unavailable>) at NetTCP.swift:192 [opt]
zaraapp_1  |     frame #17: 0x0000555555c8bb1d issueServer`WebSocket.sendMessage(op=<unavailable>, bytes=0 values, final=<unavailable>, completion=0x0000555555c90a70 issueServer`closure #1 () -> () in PerfectWebSockets.WebSocket.close() -> ()partial apply forwarder with unmangled suffix ".64", self=<unavailable>) at WebSocketHandler.swift:259:15 [opt]
zaraapp_1  |     frame #18: 0x0000555555c8af09 issueServer`WebSocket.readFrame(completion:) [inlined] PerfectWebSockets.WebSocket.close(self=<unavailable>) -> () at WebSocketHandler.swift:86:9 [opt]
zaraapp_1  |     frame #19: 0x0000555555c8aeea issueServer`WebSocket.readFrame(comp=<unavailable>, self=<unavailable>) at WebSocketHandler.swift:176 [opt]
zaraapp_1  |     frame #20: 0x0000555555c9091b issueServer`partial apply for closure #1 in closure #2 in WebSocket.readFrame(completion:) [inlined] closure #1 (self=<unavailable>, comp=<unavailable>) -> () in closure #2 (Swift.Bool) -> () in PerfectWebSockets.WebSocket.(readFrame in _0CBBC1EF67015CC10ED91AFD31C801C6)(completion: (Swift.Optional<PerfectWebSockets.WebSocket.(Frame in _0CBBC1EF67015CC10ED91AFD31C801C6)>) -> ()) -> () at WebSocketHandler.swift:188:26 [opt]
zaraapp_1  |     frame #21: 0x0000555555c90913 issueServer`partial apply for closure #1 in closure #2 in WebSocket.readFrame(completion:) at <compiler-generated>:0 [opt]
zaraapp_1  |     frame #22: 0x0000555555c909f6 issueServer`partial apply for closure #1 in WebSocket.fillBufferSome(suggestion:completion:) [inlined] closure #1 (b=<unavailable>, self=<unavailable>, completion=<unavailable>) -> () in PerfectWebSockets.WebSocket.fillBufferSome(suggestion: Swift.Int, completion: () -> ()) -> () at WebSocketHandler.swift:162:4 [opt]
zaraapp_1  |     frame #23: 0x0000555555c90959 issueServer`partial apply for closure #1 in WebSocket.fillBufferSome(suggestion:completion:) at <compiler-generated>:0 [opt]
zaraapp_1  |     frame #24: 0x0000555555c2ca26 issueServer`NetTCP.readSomeBytes(cnt=<unavailable>, completion=0x0000555555c90930 issueServer`partial apply forwarder for closure #1 (Swift.Optional<Swift.Array<Swift.UInt8>>) -> () in PerfectWebSockets.WebSocket.fillBufferSome(suggestion: Swift.Int, completion: () -> ()) -> () at <compiler-generated>, self=<unavailable>) at NetTCP.swift:177:4 [opt]
zaraapp_1  |     frame #25: 0x0000555555c8b051 issueServer`closure #2 in WebSocket.readFrame(completion:) [inlined] PerfectWebSockets.WebSocket.fillBufferSome(suggest=32768, completion=<unavailable>, self=<unavailable>) -> ()) -> () at WebSocketHandler.swift:157:15 [opt]
zaraapp_1  |     frame #26: 0x0000555555c8b03b issueServer`closure #2 in WebSocket.readFrame(b=<unavailable>, comp=<unavailable>, self=<unavailable>) at WebSocketHandler.swift:187 [opt]
zaraapp_1  |     frame #27: 0x0000555555c8ac23 issueServer`closure #1 in WebSocket.fillBuffer(b=<unavailable>, self=<unavailable>, completion=<unavailable>) at WebSocketHandler.swift:152:4 [opt]
zaraapp_1  |     frame #28: 0x0000555555c2c4c7 issueServer`NetTCP.readBytesFully(buffer=<unavailable>, read=<unavailable>, remaining=<unavailable>, timeoutSeconds=0, completion=0x0000555555c8bc80 issueServer`partial apply forwarder for closure #1 (Swift.Optional<Swift.Array<Swift.UInt8>>) -> () in PerfectWebSockets.WebSocket.fillBuffer(demand: Swift.Int, completion: (Swift.Bool) -> ()) -> () at <compiler-generated>, self=<unavailable>) at NetTCP.swift:131:4 [opt]
zaraapp_1  |     frame #29: 0x0000555555c3788e issueServer`partial apply for closure #1 in NetTCPSSL.readBytesFullyIncomplete(into:read:remaining:timeoutSeconds:completion:) [inlined] closure #1 (w=<unavailable>, completion=0x0000555555c8bc80 issueServer`partial apply forwarder for closure #1 (Swift.Optional<Swift.Array<Swift.UInt8>>) -> () in PerfectWebSockets.WebSocket.fillBuffer(demand: Swift.Int, completion: (Swift.Bool) -> ()) -> () at <compiler-generated>, self=<unavailable>, to=<unavailable>, read=<unavailable>, remaining=<unavailable>, timeoutSeconds=<unavailable>) -> () in PerfectNet.NetTCPSSL.readBytesFullyIncomplete(into: PerfectNet.ReferenceBuffer, read: Swift.Int, remaining: Swift.Int, timeoutSeconds: Swift.Double, completion: (Swift.Optional<Swift.Array<Swift.UInt8>>) -> ()) -> () at NetTCPSSL.swift:332:10 [opt]
zaraapp_1  |     frame #30: 0x0000555555c37880 issueServer`partial apply for closure #1 in NetTCPSSL.readBytesFullyIncomplete(into:read:remaining:timeoutSeconds:completion:) at <compiler-generated>:0 [opt]
zaraapp_1  |     frame #31: 0x0000555555c2960a issueServer`partial apply for closure #1 in closure #1 in static NetEvent.add(socket:what:timeoutSeconds:callback:) [inlined] closure #1 (callback=<unavailable>, s=<unavailable>, f=<unavailable>) -> () in closure #1 (Swift.Int32, PerfectNet.NetEvent.Filter) -> () in static PerfectNet.NetEvent.add(socket: Swift.Int32, what: PerfectNet.NetEvent.Filter, timeoutSeconds: Swift.Double, callback: (Swift.Int32, PerfectNet.NetEvent.Filter) -> ()) -> () at NetEvent.swift:275:5 [opt]
zaraapp_1  |     frame #32: 0x0000555555c295ec issueServer`partial apply for closure #1 in closure #1 in static NetEvent.add(socket:what:timeoutSeconds:callback:) at <compiler-generated>:0 [opt]
zaraapp_1  |     frame #33: 0x0000555555917eb9 issueServer`thunk for @escaping @callee_guaranteed () -> () at <compiler-generated>:0 [opt]
zaraapp_1  |     frame #34: 0x00007ffff7f69547 libdispatch.so`_dispatch_call_block_and_release + 7
zaraapp_1  |     frame #35: 0x00007ffff7f712aa libdispatch.so`_dispatch_continuation_pop + 410
zaraapp_1  |     frame #36: 0x00007ffff7f71018 libdispatch.so`_dispatch_async_redirect_invoke + 248
zaraapp_1  |     frame #37: 0x00007ffff7f7dbaa libdispatch.so`_dispatch_worker_thread + 602
zaraapp_1  |     frame #38: 0x00007ffff76796db libpthread.so.0`start_thread + 219
zaraapp_1  |     frame #39: 0x00007ffff47da88f libc.so.6`clone + 63

https://stackoverflow.com/questions/60517914/webapp-crashing-when-connecting-through-a-nginx-websocket-proxy

Error during compilation from command line (travis-ci)

During compilation my application on Travis CI I have following error:

Undefined symbols for architecture x86_64:
  "static (extension in Foundation):Swift.String._unconditionallyBridgeFromObjectiveC(__ObjC.NSString?) -> Swift.String", referenced from:
      __C.StringTransform.rawValue.getter : Swift.String in Net.o
      __C.StringTransform.rawValue.getter : Swift.String in NetAddress.o
      __C.NSKeyValueChangeKey.rawValue.getter : Swift.String in NetEvent.o
      __C.RunLoopMode.rawValue.getter : Swift.String in NetEvent.o
      __C.StringTransform.rawValue.getter : Swift.String in NetEvent.o
      __C.StringTransform.rawValue.getter : Swift.String in NetNamedPipe.o
      __C.NSKeyValueChangeKey.rawValue.getter : Swift.String in NetNamedPipe.o
      ...
ld: symbol(s) not found for architecture x86_64

This started occurs when I switched to Xcode 9.3. You can easily reproduce error by executing following steps:

$ git clone https://github.com/PerfectlySoft/Perfect-Net.git
$ cd Perfect-Net
$ swift package update
$ swift package generate-xcodeproj
$ xcodebuild -scheme PerfectNet-Package -enableCodeCoverage YES clean build test

I'm using xcodebuild instead of swift build because I would like to have report from code coverage.

Similar issues on GitHub:
vapor/vapor#1624
angelolloqui/SwiftKotlin#72

SIGPIPE

I was playing with EventSource from HTML5 with Perfect library, and got this signal. Everything seems to be working if I ignore it, but it's annoying because it forces debugger break.

It's possible that I'm doing some unsupported stuff. Anyway, this code in initPipe seems to work:

var set = Int32(1);
setsockopt(fd.fd, SOL_SOCKET, SO_NOSIGPIPE, &set, UInt32(sizeof(Int32.self)));

My understanding is that ignoring is is not a problem, since error will be returned during write, but maybe I'm wrong.

swift 4.1.2 deprecated features and will be removed in a future release

$ cat /etc/lsb-release 
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"
$ swift --version
Swift version 4.1.2 (swift-4.1.2-RELEASE)
Target: x86_64-unknown-linux-gnu
$ swift build
...
Compile Swift Module 'PerfectNet' (7 sources)
/home/user/antiparsing_v3/.build/checkouts/Perfect-Net.git--9169202650391526425/Sources/NetTCPSSL.swift:779:27: warning: using '!' in this location is deprecated and will be removed in a future release; consider changing this to '?' instead
                typealias ctxCallback = (@convention(c) () -> Swift.Void)!
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.