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

End_of_file exception when doing send #92

Open
alinpopa opened this issue Jun 20, 2017 · 8 comments
Open

End_of_file exception when doing send #92

alinpopa opened this issue Jun 20, 2017 · 8 comments

Comments

@alinpopa
Copy link

alinpopa commented Jun 20, 2017

I'm trying to do something like this, just before this line: https://github.com/vbmithr/ocaml-websocket/blob/master/lwt/wscat.ml#L27

...
let _ = send @@ Frame.create ~content:"some stuff here" () in
Lwt_io.printf "> %s\n> %!" fr.content
... 

and I'm getting an End_of_file exception;
wasn't able to find anything within the documentation, or the code, that would help me to prevent that...
What I'm trying to do, in fact, is to have a periodic sender, that once at, let's say 10 seconds, will send some message to the server, and I imagine that send is used for that.
Any idea what am I missing here?

Thanks.

@vbmithr
Copy link
Owner

vbmithr commented Jun 20, 2017 via email

@alinpopa
Copy link
Author

alinpopa commented Jun 21, 2017

Sure; although the context here is quite complex: implementing a Slack client, that does various things, and one of them is to make sure the connection is up and running (yeah, I could use the pinging mechanism that the Websocket_lwt is providing, but I wanted to be able to explicitly send Slack ping messages);
This is the line that makes it fail:
https://github.com/alinpopa/mlvin/blob/lwt_test_send/src/lwt/slack_lwt.ml#L70

In order to build it, you'll need to do:

make lwt

then, to run it, you'll need a Slack token (don't worry about this one, will delete it after you've looked at it :) ):

 ./_build/default/bin/lwt/main.exe -t xoxb-201853301687-hr88hLxuogqiTIKE2X5AsVlC

so, I'm getting the following issue:

Jun 21 06:34:47.546 [info] Restarting ...
Jun 21 06:34:47.894 [info] Connected to https://mpmulti-6g61.slack-msgs.com/websocket/gaEWxQ6UJlb9MIlly98yNDSUVrfP0tGWHGTPcxAQuuBRZtmoQRvgoBJFO5a_zNu_iqYmRKe-AYBl2YYdWnmjp64GDjoODCAGEZ8qTxbAVgp2-CKpp9OQ1D2LMpjPgJpvBkvqFdtXb7XjWTShykft_NBI_OsAlOWHw86UVlTPQxg=
Jun 21 06:34:48.173 [info] LINE: {"type":"hello"}
Jun 21 06:34:48.174 [info] LINE: {"type":"reconnect_url","url":"wss://mpmulti-vap6.slack-msgs.com/websocket/vvveNy4tymXw7E_kfyYtZaTCrNoaHCpAgd6Z4z3Woe5fR-9sM4Q0Zc2lEQ4q-dUQpCq6cKsACeMeoO2ZNxZcDce9k8LpebHWC4e-QLj_va97XFY0B7R2j_T01y6r_sAaOPyOoVce7RIzW1iJNfz7H8-Ezjb7Ta8KpIfz5aVlDeQ="}
Jun 21 06:34:48.276 [error] ERROR: End_of_file
Jun 21 06:34:48.276 [info] LINE: {"type":"pong","reply_to":1001}
Jun 21 06:34:48.276 [info] LINE: {}

If removing the send @@ Frame.create ... line, everything is working fine; Initially I was planning of adding a periodic timer that will do that send @@ Frame.create ... , and that's how I noticed the issue.

Thanks.

@vbmithr
Copy link
Owner

vbmithr commented Jun 21, 2017

Ok, cannot repro the issue (programs runs fine). But I'm using bleeding edge versions of tons of libs, here is my makefile line: jbuilder build -p ipaddr,conduit,conduit-lwt,conduit-lwt-unix,cohttp,cohttp-lwt,cohttp-lwt-unix,websocket,websocket-lwt,mlvin,mlvin-lwt @install.

The code I tested is a slightly modified version of yours: http://github.com/vbmithr/mlvin#lwt_test_send

@alinpopa
Copy link
Author

And what's happening when you add a let _ = send @@ Frame.create ~content:"blah" () in, right before this line https://github.com/vbmithr/mlvin/blob/master/src/lwt/slack_lwt.ml#L45 ?

@alinpopa
Copy link
Author

I'll try with the bleeding edge repo, and see if I can reproduce the issue using your fork; thanks.

@alinpopa
Copy link
Author

Ok, getting all sort of errors when installing conduit against janestreet's bleeding edge repo...

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫
[ERROR] The compilation of conduit failed at "make".
Processing  1/2: [conduit: ocamlfind remove]
#=== ERROR while installing conduit.0.15.4 ====================================#
# opam-version 1.2.2
# os           darwin
# command      make
# path         /Users/alin/.opam/mlvin-4.04.1-bleeding/build/conduit.0.15.4
# compiler     4.04.1
# exit-code    2
# env-file     /Users/alin/.opam/mlvin-4.04.1-bleeding/build/conduit.0.15.4/conduit-5664-6d07ae.env
# stdout-file  /Users/alin/.opam/mlvin-4.04.1-bleeding/build/conduit.0.15.4/conduit-5664-6d07ae.out
# stderr-file  /Users/alin/.opam/mlvin-4.04.1-bleeding/build/conduit.0.15.4/conduit-5664-6d07ae.err
### stdout ###
# ocamlbuild -use-ocamlfind -classic-display -cflags "-w A-4-33-40-41-42-43-34-44" -plugin-tag "package(ppx_driver.ocamlbuild)" conduit.otarget
# ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package ppx_driver.ocamlbuild myocamlbuild.ml /Users/alin/.opam/mlvin-4.04.1-bleeding/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# + ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package ppx_driver.ocamlbuild myocamlbuild.ml /Users/alin/.opam/mlvin-4.04.1-bleeding/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# ocamlfind: Package `ppx_driver.ocamlbuild' not found
# Command exited with code 2.
### stderr ###
# make: *** [all] Error 10

@vbmithr
Copy link
Owner

vbmithr commented Jun 21, 2017

You need to put all the projects I mentioned in my Makefile line in the same directory and have jbuilder build all of them simultaneously!

Otherwise, I can repro your bug. I have the impression that the error is due to Slack closing the connection immediately after receiving the frame.

Do you see the "reconnect_url" line that slack sends? Don't you think you have to reconnect at this URL once you get this message? Not sure about it… but you may try.

@alinpopa
Copy link
Author

I was also thinking the same thing, that might be a Slack issue, on how Slack does all the things behind the scene; regarding the reconnect_url, that's an experimental type of message, so definitely not the thing I'm doing wrong. Anyway, thanks for you help; feel free to close this issue, it was opened more as a curiosity that I might be doing something wrong.

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

No branches or pull requests

2 participants