How to use feeds in Java/Scala

Added by Henrik about 4 years ago

Not sure I understand what needs to be done to get the feeds running, login using REST is no problem but using TCP with RSS proves to be more problematic in Scala.

Below is a simple example using SSLSocket from Scala (however should be very similar to how Java looks since im using Java libs). When I run this code the while loop just runs forever, that is im getting no response from the server.

@ val requestData: String = s"""{"cmd":"login", "args":{ "session_key":"$sessionKey"}}${10.toChar}"""

var sslsocketfactory: SSLSocketFactory = SSLSocketFactory.getDefault().asInstanceOf[SSLSocketFactory]
var sslsocket: SSLSocket = sslsocketfactory.createSocket(host, port).asInstanceOf[SSLSocket]
sslsocket.setUseClientMode(true)
sslsocket.startHandshake()
var os = new PrintStream(new BufferedOutputStream(sslsocket.getOutputStream()))
var is = new BufferedInputStream(sslsocket.getInputStream())
os.println(requestData)
Thread.sleep(1000)
os.print(s"""{"cmd":"subscribe", "args":{"t":"price", "i":"1869", "m":30}}${10.toChar}""")
while(is.available()<1) {
log.info(sslsocket.isConnected.toString)
Thread.sleep(1000)
}
val buf = new Array[Byte](is.available)
is.read(buf)
val input = new String(buf)
log.info(input)
os.close()
is.close()
sslsocket.close()@

What I expect from this code is to get a Heatbeat message in input after 5 sec but nothing ever happens. What am I missing?


Replies (82)

RE: How to use feeds in Java/Scala - Added by David about 4 years ago

Late reply, but....

I would check locally so that you send what you expect. Not going in to the java/scala parts, just how I would check in any language.

1/ Just check the network traffic. Wireshark for example. Even if you dont decrypt the ssl-traffic you can see if you send or receive data.

2/ Start a local server to connect to, and manually reply with a message to see that the code is right, and it flushes and have correct newlines. (It might be that you end with 10.toChar, but send it with println, which will add atleast newline, and maybe \\r. And error might disconnect you or something)

An easy way to start a local server with ssl is to use ncat.  It is like netcat, but with ssl/support.  Can be downloaded here: http://nmap.org/ncat
For example run with: ncat -v --ssl -l 1234
That will listen on port 1234, with ssl, and give you nice debug messages. Connect with a browser, curl or whatever to https://127.0.0.1:1234 just to see the output. After that, set 127.0.0.1:1234 as your feed endpoint, to see what you send. You can also reply by pasting your reply-messages to the window. You can also log it to file with -x or -o for further inspection.

3/ If all failed so far, connect to nordnet with ncat. Log in via rest, craft your payload in a text editor, and then paste or pipe them to ncat. (If you run windows, I dont know about newlines when pasting though)

Hope this helps. Cheers

RE: How to use feeds in Java/Scala - Added by website 2 months ago

The virtual casino online games run using powerful computers called "servers" that allow anyone on the planet to play their games via an internet browser. [url=https://totoca.net]먹튀검증[/url]

RE: How to use feeds in Java/Scala - Added by website 2 months ago

The Best casino company. The licensing requirements necessary for you state can also require the casino company to be licensed. There were occasions in New Jersey where a non profit organization called a casino party company and neither of the parties knew the laws resulting in the case being stopped and fines.토토커뮤니티

https://royalcbd.com/cbd-vs-thc/ - Added by website 2 months ago

Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. https://royalcbd.com/cbd-vs-thc/

RE: How to use feeds in Java/Scala - Added by website about 1 month ago

I think that thanks for the valuabe information and insights you have so provided here.All Season Tires Ottawa

RE: How to use feeds in Java/Scala - Added by website about 1 month ago

It is a great website.. The Design looks very good.. Keep working like that!. best steaming herbs for women

RE: How to use feeds in Java/Scala - Added by Currier about 1 month ago

It is an extraordinary site. The Design looks excellent. Continue working that way https://www.mycfavisit.onl/

RE: How to use feeds in Java/Scala - Added by Mike about 1 month ago

An RSS document is an XML file which can be used to publish blog entries and news. The format of the XML file is specified via the RSS specification.

RSS stands for Really Simple Syndication (in version 2.0 of the RSS specification).

Typically a RSS file is provided by a web server, which RSS client read. These RSS clients parse the file and display it.

RE: How to use feeds in Java/Scala - Added by Mike about 1 month ago

Mike wrote:

An RSS document is an XML file which can be used to publish blog entries and news. The format of the XML file is specified via the RSS specification.

RSS stands for Really Simple Syndication (in version 2.0 of the RSS specification). Bluestacks.red Omegle.red

Typically a RSS file is provided by a web server, which RSS client read. These RSS clients parse the file and display it.

RE: How to use feeds in Java/Scala - Added by website about 1 month ago

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.microbt whatsminer m31

RE: How to use feeds in Java/Scala - Added by website about 1 month ago

This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.토토사이트

RE: How to use feeds in Java/Scala - Added by Johnson about 1 month ago

Thanks for sharing this information https://www.myloweslife.vip/

RE: How to use feeds in Java/Scala - Added by website about 1 month ago

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.먹튀올

The jersey devil - Added by website about 1 month ago

Probably the cryptid most associated with a particular place, the Jersey Devil has been part of New Jersey folklore since the colonial era. The jersey devil

RE: How to use feeds in Java/Scala - Added by Sami about 1 month ago

This is great thread I really love https://biggbosstvshow.com/bigg-boss-telugu-vote/ reading all the answers.

keto advanced weight loss reviews - Added by website about 1 month ago

The ketogenic diet for beginners works by gradually drawing your body into a state of ketosis. While you are in this state, fat is becomes an important and only source of energy. keto advanced weight loss reviews

https://nightking.net - Added by website about 1 month ago

I want to say thanks for beautiful blog sharing with us. Your blog really great resource to update my knowledge. https://nightking.net

b2b marketing agency - Added by website about 1 month ago

If you are looking for a B2B marketing agency, then your search ends at this blog. We have spent over 100 hours exploring the best B2B companies in 2020. b2b marketing agency

https://varkredit.se/ - Added by website about 1 month ago

You are employed and you need to quickly obtain materials where household equipment? VARKREDIT offers you a loan to accompany you with your purchase https://varkredit.se/

solar systems off grid - Added by website about 1 month ago

Are you seeking the experts in the industry to guide you through the options, rebates, paperwork, installation, and to design the right system for your needs? solar systems off grid

RE: How to use feeds in Java/Scala - Added by website about 1 month ago

I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading. I had to go show it to my friend and he ejoyed it as well!health insurance

profile baclinks - Added by website about 1 month ago

This blog was extremely helpful. I really appreciate your kindness in sharing this with me and everyone else! profile baclinks

buffet catering company Glasgow - Added by website about 1 month ago

Many homework on the continual hunt along with offstage on the road to winning. Definitely not attached, simple to-fall as a result of wayside; And not investigation, afterward into a path travel toward the black. buffet catering company Glasgow

buffet catering service Sunderland - Added by website about 1 month ago

Your post is very helpful to get some effective tips to reduce weight properly. You have shared various nice photos of the same. I would like to thank you for sharing these tips. Surely I will try this at home. Keep updating more simple tips like this. buffet catering service Sunderland

office and corporate buffet caterers Bristol - Added by website about 1 month ago

Extraordinary things you've generally imparted to us. Simply continue written work this sort of posts.The time which was squandered in going for educational cost now it can be utilized for studies.Thanks office and corporate buffet caterers Bristol

1 2 3 4 (1-25/82)