Coder Social home page Coder Social logo

Comments (15)

robotconscience avatar robotconscience commented on June 19, 2024

Ah! Are you working with the master branch? Just realized I updated to the newest libwebsockets but only compiled for mac and win. Compiling libwebsockets is pretty simple; if you're able to do that and submit a PR I'd be really grateful!

  1. Clone libwebsockets
  2. Build LWS:
cd /path/to/libwebsockets
mkdir build
cd build
cmake .. -DLWS_IPV6=OFF
make
  1. Move compiled lib into ofxLibwebsockets/libs/libwebsockets/lib/linuxarmv6l

from ofxlibwebsockets.

timonsku avatar timonsku commented on June 19, 2024

That seems to work, I made a PR. Though the RPI2 is ARMv7 not 6 so I added it to linuxarmv7l.

from ofxlibwebsockets.

timonsku avatar timonsku commented on June 19, 2024

While it now initializes it still seems to have some bugs.
When I use any of the server example I get:
[warning] [ofxLibwebsockets] protocol is null
The browser side (chrome) says:
websocket connection CLOSED
If I then reload the page the server is not reachable anymore from the browser and I get:

[warning] [ofxLibwebsockets] Failed to send HTTP file /home/pi/of_v20150504_linuxarmv7l_release/addons/ofxLibwebsockets/example_server_sharedcanvas/bin/data/web/index.html for /index.html

from ofxlibwebsockets.

robotconscience avatar robotconscience commented on June 19, 2024

Can you set ofLogLevel to OF_LOG_VERBOSE and post your trace here?

from ofxlibwebsockets.

timonsku avatar timonsku commented on June 19, 2024

When I load the page this gets printed. Though weirdly now it doesn't show that the connection closed, the web page just does nothing, no matter how often I reload. Without setting the log level it goes back to the previous behavior. It seems that only the index.html gets transfered in OF_LOG_VERBOSE.

It goes-> nothing happens -> hard refresh -> connection closed -> hard refresh -> index.html can't be sent anymore.

[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_FILTER_NETWORK_CONNECTION
[verbose] [ofxLibwebsockets] LWS_CALLBACK_WSI_CREATE
[verbose] [ofxLibwebsockets] LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED
[verbose] [ofxLibwebsockets] LWS_CALLBACK_LOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_ADD_POLL_FD
[verbose] [ofxLibwebsockets] LWS_CALLBACK_UNLOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_FILTER_HTTP_CONNECTION
[verbose] [ofxLibwebsockets] LWS_CALLBACK_HTTP
[verbose] [ofxLibwebsockets] LWS_CALLBACK_HTTP_FILE_COMPLETION
[verbose] [ofxLibwebsockets] LWS_CALLBACK_CLOSED_HTTP
[verbose] [ofxLibwebsockets] LWS_CALLBACK_LOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_DEL_POLL_FD
[verbose] [ofxLibwebsockets] LWS_CALLBACK_UNLOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_CLOSED_HTTP
[verbose] [ofxLibwebsockets] LWS_CALLBACK_WSI_DESTROY
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_FILTER_NETWORK_CONNECTION
[verbose] [ofxLibwebsockets] LWS_CALLBACK_WSI_CREATE
[verbose] [ofxLibwebsockets] LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED
[verbose] [ofxLibwebsockets] LWS_CALLBACK_LOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_ADD_POLL_FD
[verbose] [ofxLibwebsockets] LWS_CALLBACK_UNLOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_FILTER_HTTP_CONNECTION
[verbose] [ofxLibwebsockets] LWS_CALLBACK_HTTP
[warning] [ofxLibwebsockets] Failed to send HTTP file /home/pi/of_v20150504_linuxarmv7l_release/addons/ofxLibwebsockets/example_server_sharedcanvas/bin/data/web/favicon.ico for /favicon.ico
[verbose] [ofxLibwebsockets] LWS_CALLBACK_LOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_DEL_POLL_FD
[verbose] [ofxLibwebsockets] LWS_CALLBACK_UNLOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_CLOSED_HTTP
[verbose] [ofxLibwebsockets] LWS_CALLBACK_WSI_DESTROY
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID
[verbose] [ofxLibwebsockets] LWS_CALLBACK_GET_THREAD_ID

from ofxlibwebsockets.

robotconscience avatar robotconscience commented on June 19, 2024

Hm! Ok, try this:
In Reactor.cpp (ofxLibwebsockets/libs/ofxLibwebsockets/src), add these lines:

// top of file, after #include Reactor.h
#include "ofxLibwebsockets/Util.h"

//line 114, AFTER
/*
            if (conn == NULL){
                ofLog(OF_LOG_WARNING, "[ofxLibwebsockets] connection is null ");
            } else {
                ofLog(OF_LOG_WARNING, "[ofxLibwebsockets] protocol is null");
            }
*/
// ADD:
ofLog( OF_LOG_WARNING, "[ofxLibwebsockets] "+ getCallbackReason(reason) );

Now see what LWS event is occurring at the null protocol.

from ofxlibwebsockets.

timonsku avatar timonsku commented on June 19, 2024
[warning] [ofxLibwebsockets] protocol is null
[warning] [ofxLibwebsockets] LWS_CALLBACK_ESTABLISHED
[warning] [ofxLibwebsockets] protocol is null
[warning] [ofxLibwebsockets] LWS_CALLBACK_SERVER_WRITEABLE
[warning] [ofxLibwebsockets] protocol is null
[warning] [ofxLibwebsockets] LWS_CALLBACK_CLOSED
[warning] [ofxLibwebsockets] Failed to send HTTP file /home/pi/of_v20150504_linuxarmv7l_release/addons/ofxLibwebsockets/example_server_sharedcanvas/bin/data/web/favicon.ico for /favicon.ico
[warning] [ofxLibwebsockets] Failed to send HTTP file /home/pi/of_v20150504_linuxarmv7l_release/addons/ofxLibwebsockets/example_server_sharedcanvas/bin/data/web/index.html for /index.html

from ofxlibwebsockets.

robotconscience avatar robotconscience commented on June 19, 2024

Hm! Can you try two things for me?

  1. Test the libwebsocket examples on your RPi
  2. Change ~line 110 to this:
            if (conn == NULL){
                ofLog(OF_LOG_WARNING, "[ofxLibwebsockets] connection is null ");
            } else if (conn->ws == NULL) {
                ofLog(OF_LOG_WARNING, "[ofxLibwebsockets] websocket is null");
            } else {
                ofLog(OF_LOG_WARNING, "[ofxLibwebsockets] protocol is null");
            }

and print what's happening?

It's sometimes OK that the protocol is null, but something weird is happening with the websocket creation, I think.

from ofxlibwebsockets.

timonsku avatar timonsku commented on June 19, 2024

The libwebsocket examples are working fine.
Replacing that code results in a complete crash of the app ending with this as soons as I load the page in the browser:

[warning] [ofxLibwebsockets] protocol is null
[warning] [ofxLibwebsockets] LWS_CALLBACK_ESTABLISHED
Segmentation fault

from ofxlibwebsockets.

robotconscience avatar robotconscience commented on June 19, 2024

Oof. That doesn't make a ton of sense, but you can try changing

} else if (conn->ws == NULL) {

to

} else if (conn != NULL && conn->ws == NULL) {

Last test: can you try creating a separate html app and connecting to the websocket server? You can even test in Chrome directly through the debugger console by pasting

var ws = new WebSocket("ws://locahost:9093"); 
ws.onmessage = function(m){ console.log(m); } 
ws.onclose = function(){ console.log("closed");}

when your app is running...

from ofxlibwebsockets.

timonsku avatar timonsku commented on June 19, 2024

Unfortunately the same behavior with the snippet, with the only exception that I of course don't get any errors about not being able to send the index.html.
Changing the if statement doesn't change anything either.

Chrome output:

var ws = new WebSocket("ws://192.168.2.110:9092"); 
ws.onmessage = function(m){ console.log(m); } 
ws.onclose = function(){ console.log("closed");}

<- function ws.onclose()
VM5531:4 closed

from ofxlibwebsockets.

robotconscience avatar robotconscience commented on June 19, 2024

OK! The if statement won't fix anything, just trying to get to the bottom of your problem. I had suspected it was with libwebsocket's http server but now I don't think so. I unfortunately do not have an RPi 1 or 2 to test with and can't replicate the errors on OS X.

Something's happening internally with libwebsockets that's different on RPi.

Last thing to try is building from the exact commit I used:
warmcat/libwebsockets@c67dace

from ofxlibwebsockets.

timonsku avatar timonsku commented on June 19, 2024

Tried to do that aswell but same outcome, very weird.

from ofxlibwebsockets.

robotconscience avatar robotconscience commented on June 19, 2024

Can you try using the latest build of the library AND swapping out
ofxLibwebsockets/libs/libwebsockets/include/libwebsockets.h for the one that compiles with the lib?

I'm still pretty sure it's an internal libwebsockets error, but all I can do is suggest fixes! Apologies, all RPi stuff is contributed and not maintained by me.

from ofxlibwebsockets.

timonsku avatar timonsku commented on June 19, 2024

That works! I had to fix a function call in reactor.cpp but that was about it.
Though I also had to include the lws_config.h that got build. The only libwebsockets.h I could find was in /libwebsockets/lib/ not in the build directory.

I'll make a pull request. I also changed the sharedcanvas example though you might not want to merge that ofAppGlutWindow doesn't seem to be supported on the Pi. Wouldn't link properly if I left that in, maybe I'm just missing a library.

E: looks like GLUT isnt really supported on the Pi
https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=72654

from ofxlibwebsockets.

Related Issues (20)

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.