Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting to OpenBSD : length mismatch and invalid return #43

Closed
dohnuts opened this issue Mar 3, 2017 · 5 comments
Closed

Porting to OpenBSD : length mismatch and invalid return #43

dohnuts opened this issue Mar 3, 2017 · 5 comments
Labels

Comments

@dohnuts
Copy link
Contributor

dohnuts commented Mar 3, 2017

Hello,

After fixing compilation ( just a few defines for STAILQ and c99 )
i am trying to run the daemon.

It stays in this state and does not provide content

[2017/03/03 12:52:26:0036] NOTICE: wsi 0xc3e80cef600: TIMEDOUT WAITING on 3 (did hdr 0, ah 0xc3ee9c7d000, wl 0, pfd events 0)
[2017/03/03 12:52:26:0047] NOTICE: lws_header_table_detach: wsi 0xc3e80cef600: ah held 6s, ah.rxpos 0, ah.rxlen 0, mode/state 0 4,wsi->more_rx_waiting 0

i ran it like this :
ttyd -O --debug 7 --index /usr/ports/pobj/ttyd-1.3.0/ttyd-1.3.0/html/index.html /bin/ksh

When the daemon serve small file it s okay, but it looks like the c code forgot to write when
the socket is ready.

curl http://127.0.0.1/ show the html package file is cut :

break;case"m":p="0m";break;default:this._terminal.error("Unknown DCS Pt: %s.",p),p=""}this._terminal.send(s.C0.ESC+"P"+ +f+"$r"+p+s.C0.ESC+"\\");break;case"+p":break;case"+q":p=this._terminal.currentParam,f=!1,this._terminal.send(s.C0.ESC+"P"+ +f+"+r"+p+s.C0.ESC+"\\");break;default:this._terminal.error("Unknown DCS prefix: %s.",this._terminal.prefix)}this._terminal.currentParam=0,

By using nginx/1.10.1 as a proxy see https://www.nginx.com/blog/websocket-nginx/

i can load the all index.html but other error occurs :

  • WebSocket connection to 'ws://my.com/index.htmlws' failed: Error during WebSocket handshake: Unexpected response code: 502

Because the full referrer of my request is used ( i called with index.html )

By playing arounf with nginx i got something working but the issues should be fixed.

@tsl0922
Copy link
Owner

tsl0922 commented Mar 4, 2017

ttyd is not tested on OpenBSD yet, PRs are welcomed.

@tsl0922
Copy link
Owner

tsl0922 commented Mar 9, 2017

Merged #44.

I don't have OpenBSD environment right now, will check the issue you reported later.

@tsl0922
Copy link
Owner

tsl0922 commented Mar 22, 2017

Reproduced this issue on OpenBSD 6.0 last night.

However, I can't reproduce it on macOs 10.12.3, this may be an issue of the lws_serve_http_file method which comes from libwebsockets.

@tsl0922 tsl0922 added the bug label Mar 22, 2017
dohnuts added a commit to dohnuts/ttyd that referenced this issue Apr 24, 2017
Following documentation it s important to not try to reuse when lws_serve_http_file
return 0 nor to try to reuse the socket.

This fix the issue on openbsd 6.0 ( my current test is with upgraded libwebsocket 2.0.3 instead of 2.0.2 but it shouldnt matter
@dohnuts
Copy link
Contributor Author

dohnuts commented Apr 24, 2017

I tested the sofware with the proposed file change following
https://github.com/warmcat/libwebsockets/blob/master/test-server/test-server-http.c#L413

tsl0922 pushed a commit that referenced this issue Apr 25, 2017
Following documentation it s important to not try to reuse when lws_serve_http_file
return 0 nor to try to reuse the socket.

This fix the issue on openbsd 6.0 ( my current test is with upgraded libwebsocket 2.0.3 instead of 2.0.2 but it shouldnt matter
@tsl0922
Copy link
Owner

tsl0922 commented Apr 25, 2017

Thanks @dohnuts ! Works great 👍

I've applied your patch with some modifications.

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

No branches or pull requests

2 participants