Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Websocket Programming, Any advice?

views
     
TSTullamarine
post Jun 8 2020, 06:10 PM, updated 4y ago

Getting Started
**
Validating
163 posts

Joined: Apr 2020
I am going to start a websocket server-client project.

The demo app was done in Java, so I have to port it to C#.
Example code from the vendor:

CODE
           URI uri = new URI("ws://" + ip + ":" + port);
           mWebSocketClient = new MyWebSocketClient(uri);
           mWebSocketClient.connect();


What's your advice in dealing with websocket (ws / wss)?

Any tool to interact with the websocket server terminal without using our own coding? There is software tool to read and write to and from serial port, so I am thinking the same about websocket.

I have not yet research on any .NET websocket API in C#, so it would be helpful to know your advice.


WongGei
post Jun 8 2020, 10:21 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
TELNET
TSTullamarine
post Jun 10 2020, 05:46 PM

Getting Started
**
Validating
163 posts

Joined: Apr 2020
QUOTE(WongGei @ Jun 8 2020, 10:21 PM)
TELNET
*
Thank you for this great hint!

BTW, does anyone know if socket programming involves ACK (acknowledge character) in communication protocol? Must I implement it myself in coding, e.g. if no ACK received within one second, it signals that the message has not reach the received end.

I shall be able to forward any programming query to China manufacturer team in regards to this websocket server-client project starting next week, but I need to come out with the prototype this week. So I am rather clueless, because ACK is needed in serial port (RS232) programming as stated in the vendor's official documentation, but I could not spot any ACK in the vendor's Socket demo (Java source code). icon_question.gif
bumpo
post Jun 11 2020, 11:03 AM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


i'm no websocket guru but what little i know tells me that ACK you describing sounded like part of tcp protocol and not websocket itself. thus you shouldnt need to care about that unless you are writing your own implementation of tcp itself sweat.gif

no mention of ACK in websocket 'specs' as well https://tools.ietf.org/html/rfc6455
WongGei
post Jun 11 2020, 11:30 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(Tullamarine @ Jun 10 2020, 05:46 PM)
Thank you for this great hint!

BTW, does anyone know if socket programming involves ACK (acknowledge character) in communication protocol? Must I implement it myself in coding, e.g. if no ACK received within one second, it signals that the message has not reach the received end.

I shall be able to forward any programming query to China manufacturer team in regards to this websocket server-client project starting next week, but I need to come out with the prototype this week. So I am rather clueless, because ACK is needed in serial port (RS232) programming as stated in the vendor's official documentation, but I could not spot any ACK in the vendor's Socket demo (Java source code).    icon_question.gif
*
This is more like the work of TCP stack. Well, it can also happen in higher level protocols. You need to check and confirm with the other party.


WongGei
post Jun 11 2020, 11:33 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(Tullamarine @ Jun 8 2020, 06:10 PM)
I am going to start a websocket server-client project.

The demo app was done in Java, so I have to port it to C#.
Example code from the vendor:

CODE
           URI uri = new URI("ws://" + ip + ":" + port);
           mWebSocketClient = new MyWebSocketClient(uri);
           mWebSocketClient.connect();


What's your advice in dealing with websocket (ws / wss)?

Any tool to interact with the websocket server terminal without using our own coding? There is software tool to read and write to and from serial port, so I am thinking the same about websocket.

I have not yet research on any .NET websocket API in C#, so it would be helpful to know your advice.
*
BTW, you can try this tools without doing programming,

http://www.drk.com.ar/builder.php
TSTullamarine
post Jun 14 2020, 01:51 PM

Getting Started
**
Validating
163 posts

Joined: Apr 2020
QUOTE(bumpo @ Jun 11 2020, 11:03 AM)
i'm no websocket guru but what little i know tells me that ACK you describing sounded like part of tcp protocol and not websocket itself. thus you shouldnt need to care about that unless you are writing your own implementation of tcp itself  sweat.gif

no mention of ACK in websocket 'specs' as well https://tools.ietf.org/html/rfc6455
*
QUOTE(WongGei @ Jun 11 2020, 11:30 AM)
This is more like the work of TCP stack. Well, it can also happen in higher level protocols. You need to check and confirm with the other party.
*
Thanks, I think I will follow their Java socket demo in the mean time. (So no ACK)

Their documentation has a lot of errors. I can't believe that this China team cannot differentiate what is "FF" (2-byte) and 0xFF (1-byte). Their Java socket demo contradicts with their documentation (in regards to communication protocol).

And another example, STX is marked as 0x02 (1-byte) in their docs, but their socket demo uses "02" ( 2-byte hexadecimal string) doh.gif . Maybe I am used to US-based technology and docs which is less error-prone.
Darrel1991
post Jun 19 2020, 12:43 PM

New Member
*
Newbie
33 posts

Joined: Mar 2018
i am using websocketsharp to cater to all your scenarios it has a lot of functional feature u can use

like OnClose,OnOpen,OnMessage Event

https://github.com/sta/websocket-sharp


Example on OnClose

if Websocket Close then u can redial


Example on OnOpen

if Websocket Open do something


u can go to your Nuget Gallery and download them u do not need to write rawly dont waste your time

Regards

Darrel
TSTullamarine
post Jun 19 2020, 04:22 PM

Getting Started
**
Validating
163 posts

Joined: Apr 2020
QUOTE(Darrel1991 @ Jun 19 2020, 12:43 PM)
i am using websocketsharp to cater to all your scenarios it has a lot of functional feature u can use

like OnClose,OnOpen,OnMessage Event

https://github.com/sta/websocket-sharp
Example on OnClose

if Websocket Close then u can redial
Example on OnOpen

if Websocket Open do something
u can go to your Nuget Gallery and download them u do not need to write rawly dont waste your time

Regards

Darrel
*
I have finished my websocket project and it works fine with handheld payment terminal. If I knew this websocketsharp earlier, definitely will take a look. I can see their syntax is very simple, some more got IsPing().

My websocket project does not have OnClose, OnOpen, OnMessage and OnError. That's one of my concern, because in my code, can receive without sending first, so it creates an issue where it keep receiving when there is nothing in return. Maybe I should limit it to one send (request) & one receive (response).

Anyway, the requirement of the payment terminal is unique, because it uses its own higher-layer of communication protocol: STX, LEN, MSG, ETX, LRC (checksum)........

Thanks for letting me know the websocketsharp.
TSTullamarine
post Jul 19 2020, 12:32 PM

Getting Started
**
Validating
163 posts

Joined: Apr 2020
Just want to add picture which show the portable device (payment terminal) that is communicated using websocket programming.

AFAIK, a few chain store outlets in Malaysia are using this.

user posted image
bumpo
post Jul 21 2020, 01:52 PM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


QUOTE(Tullamarine @ Jul 19 2020, 12:32 PM)
Just want to add picture which show the portable device (payment terminal) that is communicated using websocket programming.

AFAIK, a few chain store outlets in Malaysia are using this.

user posted image
*
i think i've seen it somewhere b4.. speedmart99 i think? hmm.gif
i could be wrong
TSTullamarine
post Jul 21 2020, 04:34 PM

Getting Started
**
Validating
163 posts

Joined: Apr 2020
QUOTE(bumpo @ Jul 21 2020, 01:52 PM)
i think i've seen it somewhere b4.. speedmart99 i think? hmm.gif
i could be wrong
*
Yes, I have seen it at SpeedMart99 also. I have no affiliation with ipay88 so this is just my wild guess.


 

Change to:
| Lo-Fi Version
0.0143sec    0.08    5 queries    GZIP Disabled
Time is now: 29th March 2024 - 05:12 AM