-
Notifications
You must be signed in to change notification settings - Fork 106
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
sending messages to already created websocket objects #34
Comments
@manish786 You cannot directly cross the request boundary to manipulate a cosocket object that the current request does not create. The This is a FAQ and has discussed for many times in the openresty mailing lists. Basically you pass data and control flow to the target request and let the target request manipulate its own cosocket. You can use worker-level Lua tables, queues based on lua_shared_dict, and/or ngx.semaphore to achieve this. |
I attempt to convert many requests (tcp raw stream request) on different connections to one websocket-connection,but I got 'bad request' error message. |
I have a list of websocket server objects that get created when client(s) call in on port A.
Another port, B listens for incoming http requests(no websockets here) on same server. The requirement is to send messages to websocket clients via already created websockets connections (on port A) based on requests on port B.
My initial hunch was just to test the created websocket object in different request contexts.
To start with, I saved the websocket server object in a global table variable. Requests on port B seem to have access to earlier saved websocket object. Tried sending text using this object through it resulted in error:
Any insights? I was going to try the ngx.shared.DICT next but wanted to check with you all. I am new to openresty and Lua
The text was updated successfully, but these errors were encountered: