Comments (15)
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!
- Clone libwebsockets
- Build LWS:
cd /path/to/libwebsockets
mkdir build
cd build
cmake .. -DLWS_IPV6=OFF
make
- Move compiled lib into ofxLibwebsockets/libs/libwebsockets/lib/linuxarmv6l
from ofxlibwebsockets.
That seems to work, I made a PR. Though the RPI2 is ARMv7 not 6 so I added it to linuxarmv7l.
from ofxlibwebsockets.
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.
Can you set ofLogLevel to OF_LOG_VERBOSE and post your trace here?
from ofxlibwebsockets.
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.
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.
[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.
Hm! Can you try two things for me?
- Test the libwebsocket examples on your RPi
- 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.
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.
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.
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.
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.
Tried to do that aswell but same outcome, very weird.
from ofxlibwebsockets.
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.
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)
- File Upload Question
- Corrupted data server side?
- example_server_echo not able to load jquery from RPI3
- net::ERR_CONTENT_LENGTH_MISMATCH HOT 1
- The addon will not be compatible with ofx 0.10.0 in windows HOT 5
- compiling on rpi HOT 4
- Problem with ubuntu 18 and workaround HOT 2
- Current windows libs are 64-bit exclusively HOT 1
- When compiling on OS X: Undefined symbols for architecture x86_64: HOT 1
- SSL connection Issue
- Add 64-bit requirment note to Readme HOT 1
- Can the Video Blob examples be built on Windows 10 X64
- handling args.json has compile errors
- 'bool ofxTurboJpeg::compress<ofImage>(T &,int,unsigned long)': cannot convert argument 3 from 'unsigned long *' to 'unsigned long' example_server_blob C:\Users\Thea\Desktop\of_v0.9.7_vs_release\addons\ofxLibwebsockets\example_server_blob\src\ofApp.cpp 158
- Race condition
- crypto.a and ssl.a paths in addon_config.mk HOT 2
- Memory leak when sending a video as binary
- Error may be due to dependancy? HOT 2
- Feature Request - blocking methods for send() and receive()? HOT 1
- Why is it requring websockets.lib?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ofxlibwebsockets.