Closed Knutselsmurf1 closed 3 years ago
It's not recommended to mix different Ulfius versions.
Ubuntu 20.04 provides Ulfius 2.5.2 while Ulfius' current version is 2.6.9.
The package libulfius-dev in Ubuntu provides the example programs.
So I suggest you use the Ubuntu example source code or install a pre-compiled package in the release page.
Check the install documentation for more details.
Erratum: I just realized the cmake script for websocket server example is incomplete, the static files are missing when you run the program. You can add a link to the static files in the build directory, that would fix the issue:
$ cd example_programs
$ mkdir build
$ cd build
$ cmake ..
$ make
$ ln -s ../websocket_example/static/ .
$ ./websocket_server
I will fix the cmake script in the next release, thanks!
I originally started with source code for Ulfius 2.5.2. However I ran into exactly the same issue as #123 (and therefore I tried 2.6 as suggested).
Unfortunately this addition does not solve the segmentation fault: $ ln -s ../websocket_example/static/ .
The example programs are deployed in /usr/share/doc/libulfius-dev/examples. However I am not sure how and if I can use directly.
That's right, I forgot about this old bug, therefore I suggest you use the example_programs
from the source package 2.6.9.
The point of the link is because the program websocket_server
expects a directory static
that contains the static html, css and javascript files.
In the end, you should have the executable websocket_server
and a directory static
in the same path and run websocket_server
from this path.
The example programs are deployed in /usr/share/doc/libulfius-dev/examples. However I am not sure how and if I can use directly.
Not directly from /usr/share/doc/libulfius-dev/
but you can copy this folder into your working directory.
Unfortunately it does not matter if I take the websocket_example from 2.6.9 or 2.6 instead 2.5.2. All results in Segmentation fault if I enter in a browser http://localhost:9275/static/index.html
I also tried to copy folder /static to my build directory instead using the link.
There might be several reasons for this problem to happen so let's restart the process if you're ok.
example_programs/websocket_example/
example_programs/websocket_example/
, run make test_server
Then you should see an output like this:
cd ../../src && make debug JANSSONFLAG=1
make[1]: Entering directory '/opt/ulfius/src'
Config file ../include/ulfius-cfg.h generated
JANSSON SUPPORT DISABLED
CURL SUPPORT ENABLED
GNUTLS SUPPORT ENABLED
WEBSOCKET SUPPORT ENABLED
YDER SUPPORT ENABLED
FREERTOS SUPPORT DISABLED
LWIP SUPPORT DISABLED
gcc -c -pedantic -std=gnu99 -fPIC -Wall -Werror -Wextra -D_REENTRANT -I../include -DDEBUG -g -O0 ulfius.c
gcc -c -pedantic -std=gnu99 -fPIC -Wall -Werror -Wextra -D_REENTRANT -I../include -DDEBUG -g -O0 u_map.c
gcc -c -pedantic -std=gnu99 -fPIC -Wall -Werror -Wextra -D_REENTRANT -I../include -DDEBUG -g -O0 u_request.c
gcc -c -pedantic -std=gnu99 -fPIC -Wall -Werror -Wextra -D_REENTRANT -I../include -DDEBUG -g -O0 u_response.c
gcc -c -pedantic -std=gnu99 -fPIC -Wall -Werror -Wextra -D_REENTRANT -I../include -DDEBUG -g -O0 u_send_request.c
gcc -c -pedantic -std=gnu99 -fPIC -Wall -Werror -Wextra -D_REENTRANT -I../include -DDEBUG -g -O0 u_websocket.c
gcc -c -pedantic -std=gnu99 -fPIC -Wall -Werror -Wextra -D_REENTRANT -I../include -DDEBUG -g -O0 yuarel.c
gcc -shared -fPIC -Wl,-soname,libulfius.so -o libulfius.so.2.6.9 ulfius.o u_map.o u_request.o u_response.o u_send_request.o u_websocket.o yuarel.o -L/usr/local/lib -lc -lmicrohttpd -lorcania -lpthread -lyder -lcurl -lgnutls
ln -sf libulfius.so.2.6.9 libulfius.so
make[1]: Leaving directory '/media/donjon/workspace/angharad/ulfius/src'
gcc -c -Wall -I../../include -I../include -I../../example_callbacks/static_file ../../example_callbacks/static_file/static_file_callback.c
gcc -c -Wall -I../../include -I../include -I../../example_callbacks/static_file websocket_server.c
gcc -o websocket_server websocket_server.o static_file_callback.o -lc -lulfius -lorcania -L../../src -lyder
LD_LIBRARY_PATH=../../src: ./websocket_server
2020-10-12T19:48:48Z - websocket_example INFO: Starting websocket_example
2020-10-12T19:48:48Z - websocket_example INFO: Start framework on port 9275 http mode
There, open http://localhost:9275/static/index.html and try again the websocket example.
If you still have the segfault, install the package valgrind and run make memcheck_server
, try to crash the program again, if you still have the segfault, open the file valgrind_server.txt
which is valgrind's log output. There you should see a message like Process terminated
somewhere which might help us pointing out where the problem is.
If I run from /example_programs/websocket_example/ then it works: $ make test_server
So I looked further and I know what I have done wrong:
The full steps to make it workable:
Issue solved, thank you.
I have installed Ubuntu 20.04.1 LTS in Hyper-V virtual environment.
I installed Ulfius: $ sudo apt install libulfius-dev uwsc
I downloaded the examples 2.6 and compiled them: $ cd example_programs $ mkdir build $ cd build $ cmake .. $ make
$ ./websocket_server
If I open http://localhost:9275/static/index.html then it crashes “Segmentation fault (core dumped)”? However I tried as suggested in #123, the 2.6 code. Did I miss something?
Can or should I use a later Ulfius, or will become a later Ulfius the default version for Ubuntu 20.04 LTS?