Comments (9)
from socketcluster-client-java.
Hey I think I can point you to the example from where you can replicate for the same.
import logging
from socketclusterclient import Socketcluster
logging.basicConfig(format="%s(levelname)s:%(message)s", level=logging.DEBUG)
import json
api_credentials = json.loads('{}')
api_credentials["apiKey"]="xxx"
api_credentials["apiSecret"]="xxx"
def your_code_starts_here(socket):
###Code for subscription
socket.subscribe('TRADE-OK--BTC--CNY') # Channel to be subscribed
def channelmessage(key, data): # Messages will be received here
print ("\n\n\nGot data "+json.dumps(data, sort_keys=True)+" from channel "+key)
socket.onchannel('TRADE-OK--BTC--CNY', channelmessage) # This is used for watching messages over channel
###Code for emit
def ack(eventname, error, data):
print ("\n\n\nGot ack data " + json.dumps(data, sort_keys=True) + " and eventname is " + eventname)
socket.emitack("exchanges",None, ack)
socket.emitack("channels", "OK", ack)
def onconnect(socket):
logging.info("on connect got called")
def ondisconnect(socket):
logging.info("on disconnect got called")
def onConnectError(socket, error):
logging.info("On connect error got called")
def onSetAuthentication(socket, token):
logging.info("Token received " + token)
socket.setAuthtoken(token)
def onAuthentication(socket, isauthenticated):
logging.info("Authenticated is " + str(isauthenticated))
def ack(eventname, error, data):
print ("token is "+ json.dumps(data, sort_keys=True))
your_code_starts_here(socket);
socket.emitack("auth", api_credentials, ack)
if __name__ == "__main__":
socket = Socketcluster.socket("wss://sc-02.coinigy.com/socketcluster/")
socket.setBasicListener(onconnect, ondisconnect, onConnectError)
socket.setAuthenticationListener(onSetAuthentication, onAuthentication)
socket.setreconnection(False)
socket.connect()
This is a logic for python client, just replicate it in java. If there is still problem, let me know about it.
from socketcluster-client-java.
from socketcluster-client-java.
from socketcluster-client-java.
Did method as write below should be automatically called while connect?
public void onSetAuthToken(String token, Socket socket) {
socket.setAuthToken(token);
}
When I debugging, the method is not called.
from socketcluster-client-java.
That is it! :D It works, it was problem in sending String , not Json object :)
Thanks!
from socketcluster-client-java.
Ohk I'm closing the issue :). Please star and fork the repo. if you like it 👍 .
from socketcluster-client-java.
Hi,
I'm using java sample written above and always get exception:
Got connect error com.neovisionaries.ws.client.WebSocketException: Failed to send an opening handshake request to the server: Received fatal alert: handshake_failure
Does it sample really work now?
from socketcluster-client-java.
I found solution for it.
I used sample with java 7. But java 7 set old TLSv1 by default. And it caused this problem.
If you set TLS to version v1.2 it will work.
from socketcluster-client-java.
Related Issues (20)
- Android client Basic listener not working HOT 19
- Upgrading the client - Sync with JS client
- Unauthorized error HOT 18
- Should be able to switch between OkHTTP and Current library
- auth before connect to socket connection HOT 5
- Missing artifacts: HOT 3
- Socket Basic Listener does not receive messages in few phones. HOT 12
- size objects HOT 2
- Upgrade Neovisionaries socket library HOT 10
- Question about Data Synchronisation HOT 1
- I am still receiving data after I stop the service of socket cluster
- perMessageDeflate no work in Android
- RFC 7692 permessage-deflate incompatible Android
- SocketCluster does not receive messages sent to channel
- Socket options similar to js client
- WebSocket sendText on a null object reference HOT 1
- Socket don't have Receiver like js client
- Please add mavencentral support, jcenter will no longer be used. HOT 2
- Could not HEAD 'https://jitpack.io/io/github/sac/SocketclusterClientJava/1.7.5/SocketclusterClientJava-1.7.5.pom'. Received status code 401 from server: Unauthorized
- Unable to use getChannelByName function 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 socketcluster-client-java.