Comments (6)
I'd like to help you get this working, but I'm going to need more information. Can you post a gist with the most minimal example possible that illustrates your issue?
from easywsclient.
See my sample code here :)
https://gist.github.com/phlegx/a1ac7869ac69a177616d
PROBLEM: After the wss->send("PING"); the connection get closed. Why?
EDIT: I have see that easywsclient don't holds the connection. If I use a javascript client all works fine! Any idea?
EDIT2: If I use the simple em-websocket all works fine!
from easywsclient.
Let's break this into three distinct issues.
- The way you are accessing wss from multiple threads is not safe. You'll need to guard each access to wss with a lock, here's an example: https://gist.github.com/dhbaird/c8f57409cdb35f769759 (there's probably a simpler way to do this, with less locking or fewer threads, but this gets you started with better thread safety)
- It looks like an auto-reconnect feature might be useful to incorporate into easywsclient.
- When I try your code with ws://echo.websocket.org (instead of ws://192.168.1.10:3000), I don't get disconnected, so your issue about frequent disconnection appears to be a localized issue with your server. Do you know how long it takes to get disconnected? What server are you using?
from easywsclient.
Nice sample code! Thx π i'm happy :D
I check this code and your questions and write you back...
:D
from easywsclient.
Hi dhbaird, I am trying to use library and would like to implement full duplex communication. Basically create 2 threads and send messages from one thread and receive messages in other thread. Is this easily possible? Your solution will make communication half duplex as mutex prevents sending and receiving at the same time,
from easywsclient.
@VinodG - You could open two (or more) web socket connections, one per thread. Then you can get even better than full duplex :) I am willing to consider API ideas that can address this issue in a generic way (i.e. the details of threading or mutexes should not be built into this library, unless it is done in a generic way that is optional; But if the API can be updated in a way that makes it more useful to a user who wants to use threads and mutexes from outside of this library, then that is worth looking into.).
from easywsclient.
Related Issues (20)
- getting error when im trying to connect HOT 2
- about vector variable need be clear() and swap()
- not compiled on msys2 HOT 2
- "hostname_connect" funtion code bug
- Memory leak
- from_url() missing close(sockfd)
- Compiling
- connecting to wss through proxy
- How to add parameter at function handle_message
- helloοΌis there a bug here? HOT 1
- Update npm dependencies to resolve (harmless) security vulnerability in ws
- Check for invalid frame length HOT 1
- VS ERROR LNK2001 Unresolved external symbol easywsclient::WebSocket::from_url HOT 1
- Integrating with OSS-Fuzz HOT 5
- unable to connect: aborted
- Multiple Clients
- >65000 byte send fail
- Half closed connection not handled HOT 1
- Assertion 'ws' failed in ubuntu18.04 HOT 1
- Notifications from the server are not received HOT 1
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 easywsclient.