I am preparing to build a WebSockets system to have a bidirectional communication from my server to my clients through WebSockets.
I know that Laravel now very well supports 3rd parties like Pusher Channels and Ably.
There are also some other ways that are also very convenient and simple to use such as Laravel Websockets, soketi, laravel-echo-server.
But my problem is client-side cannot include 3rd party Client Library. My client-side is a Cross-platform Game based on Javascript and HTML5. I can only connect client-side to server-side through WebSocket.
As far as I know, when using 3rd party for server-side, I should use their JS Client Library like pusher/pusher-js, laravel/echo ... Therefore, I can't find any documents if I want to use them with WebSocket.
My goal is to find the best and most suitable solution for both client and server side.
What I have tried?
IDEA 1: Convert pusher.js to my own js
I spent 2 weeks on this. I see this as possible and some functions might work. However, it will take a long time if I want to convert the whole thing.
IDEA 2: Using Pusher and connect the client via Pusher Channels Protocol
I have tested them as follows
var socket = new WebSocket('ws://ws-[cluster_name].pusher.com:[port]/app/[key]');
It worked. I can see them connected on the Pusher Debug Console. However, I can't find any documentation regarding the basics like Subcribe channel, Listening events, Send message to other client, Ping, Pong, ...
IDEA 3: Using Laravel Websockets
Like idea 2, I couldn't find any documentation or examples.
IDEA 4: Using NodeJS instead of Laravel. Choose ws packages
I tried it and it worked as expected. WS is really simple but it is exactly what I want. However I don't have many years of NodeJS experience. Therefore, I feel there are many risks if I choose it to build a new project.
Could you tell me a best way to deal with this problem?
Thanks
The Pusher and Laravel Echo JavaScript clients work with any Pusher-compatible websockets host. (Pusher uses websockets, too.)
All it takes is a little configuration; see, for example, Laravel Websockets' guide on configuring Laravel and then configuring Echo. Both steps point your Pusher requests at your chosen Pusher replacement instead.
No need to write your own library or manually consume websocket data.
Related
I would like to send messages from my Java server to my react-native clients.
I don't know exactly how to solve this. Should the server establish a connection to all clients via the IP addresses of the clients and send the message and then close the connection again? (Sounds the most sensible to me.)
I think that would be better than if the clients connected to the server and the connection should always be maintained. After all, it should run with high performance.
Basically, it doesn't make much sense for my system that the clients connect to the server, since only the server knows when and whether it is sending a message.
I've already tried working with websockets. However, it didn't seem to work without requests from clients.
The difficulty is to find a method that works with Java on the server side and JavaScript on the client side and that the connection is made from the server to the clients and not from the clients to the server. In addition, the transmission should work in real time.
Is that feasible? Are there any better ways? How can I do it?
I hope you can help me.
Greetings. Martin
The basic function of the system
There are multiple cloud based messaging platforms. One of them is Firebase from Google which is free (I guess). Check this out here. https://firebase.google.com/docs/cloud-messaging
You will find multiple tutorials to configure and use it in your react-native and Java server.
Architectural overview: https://firebase.google.com/docs/cloud-messaging/fcm-architecture
Another solution is writing your own logic using the WebSockets.
Lifecycle of message: https://firebase.google.com/docs/cloud-messaging/fcm-architecture#lifecycle_flow
I am aiming to create a WebRTC chat (video/audio) application and most of tutorials and demos that I see are using the following signaling channel:
signaling.simplewebrtc.com:8888
I even found this great demo, where the developer stated that it does not depend on this signaling channel, but when I went through the code I found it there.
Can someone explain me, how can I substitute this with my own signaling channel?
I do not completely understand your question. I guess the URL you provided points to an websocket server. Websockets are often used for signaling because they provide a permanent, full-duplex connection (this means that the server is able to push messages to the client without an previous request).
You have to exchange network information between the two parties who want to set up an RTCPeerConnection because of NAT and firewalls etc... How to exchange that information is not part of the WebRTC-specification. You can use any protocol you want, HTTP,Websockets, even EMail (but that would be pretty ugly to implement :) ). But if you want to build your own signaling-server using node.js you can have a look at the tutorial I am currently writing. It explains in detail how to setup your own very simple video-chat using WebRTC and a Node-Server hosted on uberspace.de:
Tutorial: Create your own Videochat-Application with HTML and JavaScript
If you use my tutorial it would be great if you could tell me if it is understandable.
Edit:
As I am still getting requests for this old tutorial, please use an up to date one like those:
https://www.baeldung.com/webrtc
https://www.html5rocks.com/en/tutorials/webrtc/basics/
Please take a look at this excellent blog on the signaling options that are available for WebRTC.
I have listed a few important blogs and sample WebRTC applications that you might also want to review to help you build your chat application.
I installed nodejs from Install NodeJS along with the required dependencies at signalmaster
Ran node server.js in cmd.
And server started running.
P S: Change url option present in simplewebrtc.bundle.js
Let me know if you face any problem
I wonder why no one has mentioned this so far . You can also use the sip framework based webrtc libraries and clients such as sipml5 , jssip etc . Additionally since you mentioned you would like your own server setup to cater to signalling requests , you will have a wide variety of websockets based sip servers to choose from such as officesip , kamailio , mobicents etc .
You can try and modify the the latest application that ships with Mobicents at https://code.google.com/p/sipservlets/wiki/HTML5WebRTCVideoApplication that allows you to chat and video chat.
I have been working with node.js for a while, now when I'm looking deeper into it, for a chat aplication instead of sending message as client - server - client, there must be some possible ways for direct client to client message sending?
Browsers tend to communicate with servers via HTTP. Some implement other protocols, like websockets & SPDY, but again, these are mostly client-server protocols.
Some plug-ins (like Flash & Java) can open ports and communicate client-client. (AFAIK, haven't actually used them.)
Chrome is the only browser I'm aware of that can (soon) open TCP and UDP sockets from Javascript and do direct client-client communication. At the moment normal web apps can't do this, your app needs to be run as a "Chrome Packaged App", with a special manifest file.
Here are the docs, a blog post describing the feature and a browserify module that can behave like the net node.js module in the browser.
EDIT: This should probably not be tagged as [node.js] since you're trying to run in browsers (not in your node vm), this is a Javascript / Browser question.
This is maybe out of date question, but take a look on PeerJS.
It requires server only as a connection manager (broker). But all communication is done between clients directly.
This does not have anything with server. If you need something like that and if clients are flash you can use RTMFP . For JS i google this library which is js bridge for RTMFP, I dont know how it works. At the end you can write you own library to chat beetween clients but this is much harder(IP addresses are behind NAT, etc...)
I think answer for your question is here
PS Also exist open-source in-browser server which written using JS, but I didn't google it quickly. If you find it, please notify me.
If you just don't want to write your own server you can use:
https://httprelay.io
Use AJAX calls to communicate between peers.
There is a server I need to talk to that publishes a protocol over TCP/IP for querying data from a database and listening on a socket to receive notifications when data is updated. The sever guys provide a Java API which uses this TCP protocol. This means I could easily write a Swing App to talk to this server.
I would like a browser based solution. As the protocol is known to me, could I do this in JavaScript? My app will have to display the data in a table. I have heard of Web Sockets but I'm not sure if it will allow this two way communication. Is it feasible? Is there a better way that is cross platform and will work in most browsers? Should I be considering a Java Swing based solution that runs inside a browser?
EDIT: What about changing the code in my C++ server to add an additional interface that my Javascript code can communicate directly with it?
The WebSocket protocol differs from TCP/IP sockets. You will have to write something to link them together.
You can do this perfectly well in JavaScript: use Node.js. There's enough tutorials to be found on the subject. The best way to link it to your in-browser JS is through Socket.IO.
Create a Node.js server that connects to the api
Make the server talk to your web app
Use it :)
This will work cross-platform and cross-browser (Socket.IO can use/emulate websockets even on IE6(!!)). You'll have to run a server-app (the Node.js app) though.
My personal opinion is that if you want a web/browser based solution, you should use native technology, and not Java.
Hope this helps :)
Introduction: I want to develop the chat client that user can chat on the browser and I use the protocol call xmpp. Because of HTML5 web socket not yet available I try flash xmlsocket instead.
Problem: I cannot connect to the server via browser. I'm not sure why, but I think that it is the problem of the server configuration.
Question: Which is the best jabber server suitable for this job?
Most probably this is a permission issue. Either that or you've just configured the wrong host/port to connect to. Flash is not allowed to connect to other hosts than the one it was gotten from itself. You have to explicitely allow flash connections on the receiving side of the request (so on the chat server that you are connecting to). Google for crossdomain.xml to get more info.
ejabberd sounds like a suitable option for you. ejabberd is xmpp server written in erlang and is used quite widely. Many of the well known web based im services like www.meebo.com etc are known to be running on ejabberd. It allows you to install other transports which would let you enable talking to users of other protocol like yahoo, msn, icq etc.
You can also have a look at the xiff action script library by ignite realtime. It is an xmpp client library in action script. If you use this library you would just need to implement the ui components.
Hum... flash is ok, but you'd be better of using something like BOSH, which is basically an HTTP layer over XMPP.
Ejabberd would be a good server, as it supports BOSH, I don't know about OpenFire or Tigase (but I'd say they do). Other servers should be looked at carefully because they don't seem to have a "dynamic" community.
You will need a lot of Javascript, and for that, I can recommend StropheJS, which is probably the very best library out there today.
We have created a MUC (Multi-user chat room) client called Aristochat that works in the browser recently at Superfeedr. You can find the code on Github and an example here.