How to use secure websocket (wss) in Tornado - qt

I'm new to Tornado and web services in general. In my application, I've Qt/c++ client and python Tornado on server side. The Qt client sends commands in the form of text messages(e.g. "ws://192.121.1.213:8080?function=myfunction?args=params..").Now, I want to use secure web socket i.e. wss in stead of ws. What changes are required on server and client side? Pointer to any online example would be also helpful. Thanks.

Pass the ssl_options argument when constructing your HTTPServer:
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_ctx.load_cert_chain(os.path.join(data_dir, "mydomain.crt"),
os.path.join(data_dir, "mydomain.key"))
HTTPServer(applicaton, ssl_options=ssl_ctx)
http://www.tornadoweb.org/en/stable/httpserver.html#http-server

Related

HTTP Client in DoFn

I would like to make POST request through a DoFn for a Apache Beam Pipeline running on Dataflow.
For that, I have created a client which instanciate an HttpClosableClient configured on a PoolingHttpClientConnectionManager.
However, I instanciate a client for each element that I process.
How could I setup a persistent client used by all my elements?
And is there other class for parallel and high-speed HTTP requests that I should use?
You can put the client into a member variable, use the #Setup method to open it, and #Teardown to close it. Implementation of almost all IOs in Beam uses this pattern, e.g. see JdbcIO.

Create Channel from Socket in grpc-java

I'm using grpc in my project, the client side is written in Java and the server side is written in C++.
My question is, in the client side, is there a way to create the ManagedChannel from an existing Socket object instead of calling ManagedChannelBuilder.forAddress(host, port)?
No, it's not possible.
See also: https://github.com/grpc/grpc-java/issues/3132

Unity Client-Server separate different and State Synchronization?

As what title said, i still confusing and turn around in deep-hole and get lost about one month in it. So i really need help.
I would like to create client-server online game, and separate Client and Server to different project with each other, and for understanding, i don't using any NetworkManager and script from demo project.
Why i do that ? I want client is always remote client, and server always dedicated server that mean no local client.
All communication until now i using custom message from MessageBase and it ok for me. But the problem come with spawn game object, sync with all remote client, i don't know how to do that.
The server just handle connection, message and send back to client so it just GUI only, then i want to ask that it MUST be share scenes at client ? Does it NEED TO DO IT ?
The client is a remote client, so how to sync movement, spawn, and etc to another client via server ? If i using transfer message base on MessageBase, it look so complicate than using SyncVar or Command. But i don't know how Server handle Command, because it separate different with Client. Can anyone help ?
AM I WRONG WAY ?

Understanding websockets in terms of REST and Server vs Client Events

For a while now I have been implementing a RESTful API in the design of my project because in my case it is very useful for others to be able to interact with the data in a consistent format (and I find REST to be a clean way of handling requests). I am now trying to not only have my current REST API for my resources, but the ability to expose some pieces of information via a bidirectional websocket connection.
Upon searching for a good .net library to use that implements the websocket protocol, I did find out about SignalR. There was a few problems I had with it (maybe specific to my project?)
I want to be able to initialize a web socket connection through my
existing REST API. (I don't know the proper practice to do this, but
I figured a custom header would work fine) I would like them (the
client) to be able to close the connection and get a http response
back (101?) to signify its completion.
The problem I had with SignalR was:
that there was no clean way outside of a hub instance to get a user's connection id and map it to a external controller where the rest call made affects what piece of data gets broadcasted to the specific client (I don't want to use external memory)
the huge reliance on client side code. I really want to make this process as simple to the client and handle the majority of the work on the server side (which I had hoped modifying my current rest api would accomplish). The only responsibility I see of a client is to disconnect peacefully.
So now the question..
Is there a good server side websocket library for .net that implements the latest web socket protocol? The client can use any client library that adheres to the protocol. What is the best practice to incorporate both web socket connections and a restful api?
ASP.NET supports WebSockets itself if you have IIS8 (only Windows 8/2012 and further). SignalR is just a polyfill,
If you do not have IIS8, you can use external WebSocket frameworks like mine: http://vtortola.github.io/WebSocketListener/
Cheers.

Possible for webservice to send message from server to client?

I'm pretty sure this isn't possible with HTTP 1.1 or webservices, but just want to double check with you guys (and thus will probably be switching this application to WCF).
I want to send a message from the server an asp.net webservice is running on, to the client consuming it. Is this possible without polling (IE an interrupt based model)?
In WCF, you do have a thing called duplex bindings, which allows the server to call back into the client at a specific address.
See the MSDN documentation on duplex channels for a first impression of what those are.
I don't think you can do this with ASMX.
Marc

Resources