Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Constant "Output stream end encountered" on server #57

Open
macecchi opened this issue Sep 12, 2016 · 15 comments
Open

Constant "Output stream end encountered" on server #57

macecchi opened this issue Sep 12, 2016 · 15 comments

Comments

@macecchi
Copy link

I'm currently using PocketSocket to provide a WebSockets server. However, I'm constantly getting errors from the server socket delegate (- (void)server:server webSocket:(PSWebSocket *)webSocket didFailWithError:(NSError *)error).

Error Domain=PSWebSocketErrorDomain Code=3 "Output stream end encountered" UserInfo={NSLocalizedDescription=Output stream end encountered}

The error makes the connection to the client to stop working, but my client does not receive a close/error event, so when the client tries to send something, the socket fails (obviously). If I connect again, it works, but after a while (sometimes seconds, sometimes minutes) I get the same error.

I see from the source code that this error is related to NSStream/NSStreamEvent, but I don't know how to debug this. Can it be related to the client's WebSockets implementation?

Here's my server implementation - https://github.com/macecchi/pebble-itunesify-remote/blob/native/osx/iTunesify%20Remote/IFYPocketSocketServer.swift.

Thanks!

@macecchi
Copy link
Author

Any ideas?

@SpongeBob-GitHub
Copy link

I also get this error, how did you to fix this error??

@SpongeBob-GitHub
Copy link

but it works also error...

he can't resolve this error, he just reappear the error...

Oops...

@macecchi
Copy link
Author

I have not found a fix yet. Have you, @SpongeBob-GitHub?

@kisileno
Copy link

What version of macOS (OS X), iOS , Xcode , PocketSocket are you using?

@macecchi
Copy link
Author

I'm using PocketSocket 1.0.1 to build a macOS app, using the latest SDKs (Xcode 8, macOS 10.12), although this also happened before I upgraded to Sierra (using Xcode 8 but with macOS 10.11).

In fact, here's my project and my implementation using PocketSocket.

@kisileno
Copy link

@macecchi is AppSandbox enabled for you project?

@macecchi
Copy link
Author

macecchi commented Oct 13, 2016

Yes, but I think the issue happens with or without App Sandbox, because I only enabled that recently. Does this affect PocketSocket?

@SpongeBob-GitHub
Copy link

this error just happened with the websocket client more message stream, i fix it with a easy way: only reduce the websocket-client''s connect time, do it just the client. but it isn''t the best way to do this...

maybe, u try it with https://github.com/facebook/SocketRocket again.

@macecchi
Copy link
Author

@SpongeBob-GitHub What do you mean by "reduce the client's connect time"?

The library you pointed won't help, as I'm using PocketSocket as the server, not as the client.

@HatemMostafa
Copy link

HatemMostafa commented Mar 11, 2017

That is because PSWebSocketDriver writes data to delegate in two orders:

  • (void)writeMessageWithOpCode:(PSWebSocketOpCode)opcode data:(NSData *)data {
    .....
    // write data to delegate
    [_delegate driver:self write:header];
    [_delegate driver:self write:payload];
    }
    Your server receives the first write and try to inflate the payload with 6 bytes buffer only (header length), that inflate failed and your server closed the connection.
    You can change it to:
    // write data to delegate
    [header appendData:payload];
    [_delegate driver:self write:header];

    to force driver to send one buffer.

ngoctr added a commit to ngoctr/PocketSocket that referenced this issue Apr 5, 2017
@laoyur
Copy link

laoyur commented Jul 25, 2018

I have this problem too(PocketSocket as client)
facebook's SocketRocket does NOT help at all, still the same problem
and I am wondering that the code of SocketRocket & PocketSocket are very similar ...

@laoyur
Copy link

laoyur commented Jul 25, 2018

@HatemMostafa thanks, but it doesn't work, still the same problem.

@latenitefilms
Copy link

Did anyone ever come up with a solution or workaround for this issue? @ngoctr?

@simentt
Copy link

simentt commented Aug 14, 2020

I meet the same problem, but i don‘t think it is because of PocketSocket.
The reason for this problem is a usage problem, that is, the server generated by pocketsocket is pushing the stream, but the link on the client side is forcibly interrupted and does not go normally close.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants