I need to access a websocket server that runs with SignalR Hub, from my Java desktop application.
There is a library that does exactly that, but it's dead. There are lots of issues and pull requests and it hasn't been updated since 2015.
I also found another library but, as far as I can tell, it's only for Android projects.
I found a SO question that says it's possible to talk directly to the SignalR server (standard websocket calls) with some workarounds, but the given link is dead.
When I tried to access the server directly with websocket, the HTTP handshaking fails (I get HTTP 200 instead of 101).
Can anyone help ?
You will not be able to connect to SignalR 2.x with just bare webSocket. The reason for that is that starting the connection requires a few HTTP requests which have to be sent with in a specific order and contain specific content. I described the SignalR protocol in a blog post. After reading this post you will understand why dedicated client for SignalR 2.x existed.
Having said that - the new version of SignalR for ASP.NET Core no longer has this protocol and requirements and it is possible to connect to the server with just bare websockets. I created a demo a while ago showing how to do this - you can find details here. I also started working on an example for the hubs layer but need to finish it.
Related
I'm trying to implement WebRTC on an android device supporting API 22 and I'm trying to connect to Kurento Media Server to establish media server capabilities. For my application Server layer, I'm trying to utilize a Java Server based on Tomcat, and this is implementing a Kurento Client API to connect to the Kurento Media Server. The issue I am having is understanding how to go about establishing a connection between the Android device and Kurento and doing a media transfer after the connection has been authorized by the Application Server and a SDP response has been processed by the Kurento Client initialized on the Application/Signaling Server. I came across Kurento Android SDK (Kands) but the repositories are missing sources on Maven and Gradle. Any help here in implementing the WebRtc.org stack with Kurento would be appreciated!
KANDS will not help you much for several reasons. First, it is an outdated and unmaintained project. Second, with the setup you describe, I think you'd be barking at the wrong tree. In your case, the signalling that should be implemented in your Android client, should be between the client and your app server. As you can see in the following image, which depicts your proposed setup, your client will be connecting to an app server using your own signalling protocol, and it is you app server the one in charge of controlling KSM.
In this way, you can implement all your business logic in the app-server, and you'll be able to make upgrades in the media part, shielding your clients by hiding the underlying implementation. The only thing that you'll need, is to get the SDP offer from your client to the KMS (going through your app server), have the KMS process that offer, and send the answer back to your client.
With this setup, you'll also have the posibillity to connect Android clients to any other type of webrtc capable clients, such as browsers.
KANDS was discontinued and SDk for android is only used for them to develop customized apps. Then we switched to webview also.
I have just been introduced to the WebSocket Application Messaging Protocol WAMP http://wamp.ws/ and on googling I found the Crossbar.io implementation of the protocol.
I installed it by following http://crossbar.io/docs/Quick-Start/ and http://crossbar.io/docs/Getting-started-with-Java/ .
My goal is to wire a Java server publishing real time messages to be displayed on a web browser. Could you point me in the right direction? Once I have that setup, I can proceed with structuring the data using Ext JS or similar JavaScript frameworks.
The Getting Started with Java has all you need. Write your server-side program using the former. This component will then connect to Crossbar.io which does all the hard work of dispatching events in real-time to clients.
I am writing an iOS 5.1.1 app for the iPad2 using Xcode 4.4.1. I want to be able to locate a local http server running on Java.
Once I am able to connect to the http server, all I need to communicate with it is the url including the port.
My questions:
1) Should I use Bonjour or a DNS Server running on the http server to discover the http server itself?
2) I need to authenticate the iPad2 user with name and password to work with the http server once I discover it.
I need some help understanding how I would go about accomplishing these two steps including source code if available for the iOS 5 and Xcode 4.4.1.
1) Bonjour is pretty easy to tie in with Java apps. If you're particularly masochistic you can write your own Java-based mDNS (Bonjour) responders (I've done it, it's not rocket science), but the quickest way to get going is to use jMDNS in your http server to advertise its existence. I won't copy & paste the code samples but they suffice for most applications.
On the iOS side, NSNetService is your friend. Fundamentally it involves starting a responder in the background to look for services (i.e. your Java app), then calling a delegate when something appears/disappears:
id delegateObject; // Assume this exists.
NSNetServiceBrowser *serviceBrowser;
serviceBrowser = [[NSNetServiceBrowser alloc] init];
[serviceBrowser setDelegate:delegateObject];
[serviceBrowser searchForServicesOfType:#"_http._tcp" inDomain:#""];
There's a guide that explains it all. The protocol hasn't changed for 10+ years and you count on all modern iOS/OS X versions supporting it. The jMDNS library is pretty well battle-tested at this stage, too.
You might consider creating your own service type if you don't want it to be visible to other apps that search for _http._tcp., although this is just a cosmetic thing.
2) The simplest thing that'd work would be HTTP basic auth; you didn't say what kind of authentication your app supports or how you make HTTP requests on the client side, but this is pretty well covered already.
I'm about to start a game project. It will be a network game with client-server architecture with Java server and a Web and Android clients. Impact is on low bandwidth (for use on mobile devices) and fast response. What technologies / libraries are out there for client-server communication? I am somehow experienced in web applications (GWT/Vaadin and servlets) but have no clue what to use when implementing a game server, mainly for the communication.
I am aware that I could use Java sockets with Object serialization or maybe JSON to pass the data from client to server, but I don't know how efficient in terms of bandwidth these approaches are? Or are there any more suited than these? Just pointing me in the right direction will suffice.
Thanks in advance!
As far as Android client libraries go, there's two main options. The first is just the java.net.* package in which you'll mainly use HttpUrlConnection.
The better option is to use the Apache HTTP package that also comes standard in the Android SDK. It gives you a lot more control / flexibility / verbosity in dealing with network connections.
Here is a decent example of how to use the Apache client libraries. I suggest using these, as the java.net packages are really only suited for the most basic of GET requests.
I suggest using the JSON method, because then you're not stuck having to write a Java servlet backend to deserialize the Java objects. The backend can then change independently of the client.
The main problem is, if you use WebTechnologies, than you can't implement an efficient way to realize the communication from Server to Client ...
Client to Server over HTTP GET works fine, but you must use some kind of Comet to realise the communication from server to client.
Thats why plain old tcp connection over socket would may be the better to communicate with a Client, especially with Android Client.
But implementing it with tcp socket work great with android, but not with a Browser.
My solution: implement the communication via WebSocket.
WebSockets (part of HTML5) is a HTTP extension to enable full duplex communication between client and server.
The most major web browser support WebSocket, like Firefox 4, Chrome 9, Opera 10.7
BUT NOT the Internet Explorer (support planned in IE 10, comming with Windows 8)
And for android, there exists also java libaries to implement the communication and i would excpect, that they work also well with android.
Expample:
http://code.google.com/p/weberknecht/
For the server side: Servlet API 3.0 support that, like Jetty 8
In my opinion WebSocket would save the problem, so you can implement a single server which supports WebSocket and communicate via WebSocket to an Android client as well as with a Browser Client (except Internet Explorer)
It depends on timeframe of your project. If time is enough – try in your hands and compare the technologies related to your purposes.
I have a Node.js app that uses HTTP / REST (using Express.js), and a native Android application that communicates with this. This works fine.
I am now looking at writing a more real-time version, which can push messages to a native client. Unfortunately, it needs to be a native client, as there is some fairly complex work done with the data that simply will not be possible in a mobile browser for the forseable future (otherwise I would just wait for WebSockets support to appear in the Android browser).
So, my question is what are my options?
I know about the Android Cloud to Device Messaging framework, but this requires registration and a Google sign-in, and I would much prefer the server to be client agnostic.
Is there a reliable WebSocket client that I can use (ideally) to talk to a Node.js server running Socket.io? Or any other native method (using the NIO classes)?
See Java socket.io client
you could use https://github.com/koush/android-websockets. It is also mentioned in the socket.io wiki pages
PS: i know it is a bit late to respond to this post, but this for other like me who didn't find an answer to question like this.
compile node.js on Android natively
implement jni wrapper of node.js
...
refer this link
https://github.com/paddybyers/anode/issues/15