How to create a link between applications in golang in real time?

Good day,
You have a server and it needs to connect customers. You need to make a channel and in real time notify the server/clients.
How to make a websocket connection, but not between server/browser, and two programs in golang?
Or advise a different technology that comes out of the channel to send json data.

Thank you
July 9th 19 at 10:36
2 answers
July 9th 19 at 10:38
Solution
https://github.com/v-grabko/Core/wiki/TcpClientServer

In any case you will do the same. I just made abstraction.
See net/rpc and if applications on the same physical server then unix.socket as an address. Mindlessly copy the decision of Mr not:) - Alyson.McClure commented on July 9th 19 at 10:41
: don't not what to copy without thinking ;D. But if all that stuff is on a different server that works quite quickly. net/rpc-I have not soared. More than sure due to the fact that I'm a bad cook) - Brody_Dickins commented on July 9th 19 at 10:44
: maybe everything can be:) More about gorpc speak well, but I haven't had time to try it:) goprotoboof also almost the favorite in this case. In General there are plenty to choose.

Whether to use WebSockets for such purposes? Probably not. Because on top you still have to write a lot of logic, and if the connection will break then it is advisable to do two or more channels between two points in specialized protocols that should be better addressed. - Alyson.McClure commented on July 9th 19 at 10:47
there is not a WS and TCP socket - Brody_Dickins commented on July 9th 19 at 10:50
: goprotoboof I test. Slower almost twice. - Brody_Dickins commented on July 9th 19 at 10:53
in fact the man wanted to drive json. My solution fits the question. There wasn't anything about the ROC and the prototype buffer. Right?) - Brody_Dickins commented on July 9th 19 at 10:56
about websockets is already topikpaster asked.

Why slower (goprotoboof)? Found out the reason? - Alyson.McClure commented on July 9th 19 at 10:59
today he wants to send json but a picture tomorrow, and after tomorrow... the blockchain:) - Alyson.McClure commented on July 9th 19 at 11:02
: I guess due to the fact that data over the network more walks. - Brody_Dickins commented on July 9th 19 at 11:05
: ibid for each row type slalom etc + definitely slower than parsing json - Brody_Dickins commented on July 9th 19 at 11:08
: that extra is passed? In theory it is also binary narrowly specialized format is compiled... - Alyson.McClure commented on July 9th 19 at 11:11
: types I just passed (maybe it can be disabled. XS) - Brody_Dickins commented on July 9th 19 at 11:14
well, while I thought Jason forward type {"commadnd":"command1","data":{"param1":1}} . Responsively this I did manually without rpc (don't know how much of it professionally, but it works). Sending pictures and other data is not yet planned, but it is possible then-Yes. Another question - if I put port 80? Necessary, what would the port not blocked by firewall by default and 99% of that was open by default - without any extra installations. And if there is a http server, then in parallel they will work,as I understand, because there are different protocols? - myrtle.Bashirian commented on July 9th 19 at 11:17
: every server == a free port. On one port it will not work. Well you can hang with nginx on 80 and proxying to all other services through it. Then everything will be 80. - Brody_Dickins commented on July 9th 19 at 11:20
: and instead of the usual http rock fasthttp it faster - Brody_Dickins commented on July 9th 19 at 11:23
: What? Protobuf slower and takes more network? You something that is not so used. And types there is not Sluts they are defined in protofile. With it goes deserialization. And Yes, there is a binary message format. - sherwood_Daugherty commented on July 9th 19 at 11:26
: I yuzal what the library Gita. Maybe she was clumsy. - Brody_Dickins commented on July 9th 19 at 11:29
: to using not version 2, which is "release" and version 3, which is the type of "beta." it is beta for several years - her entire world is quiet he uses. - Katlynn_Ha commented on July 9th 19 at 11:32
: fasthttp - only makes sense in a mad load on the server.

it relieves the server, but does not add speed to the communication channel between the server and the client - there is still text and http - Katlynn_Ha commented on July 9th 19 at 11:35
: protobuf - Protocol for many years the standard inside Google, when communicating between servers. he can't be slow or slukavil. - Katlynn_Ha commented on July 9th 19 at 11:38
: and what hinders at once to write on fasthttp? He gives almost all - Brody_Dickins commented on July 9th 19 at 11:41
: incompatibility with standard stack net/http. So you won't be getting heaps of useful libraries. - Katlynn_Ha commented on July 9th 19 at 11:44
:
the speed of communication, he does not. the network between the computers depends on two programmes on the Go on both ends of the communication channel.

besides, if we are talking about bare sockets - they are significantly faster than any http, whether it is at least three times fast. - Katlynn_Ha commented on July 9th 19 at 11:47
: I would be in the TCP were not supposed to, if we are talking about maximizing speed. only UDP. - Katlynn_Ha commented on July 9th 19 at 11:50
: upd will be slower to work so skipped the delivery of packages. - Brody_Dickins commented on July 9th 19 at 11:53
and the us arranged anologii tcp I definitely don't want to do. - Brody_Dickins commented on July 9th 19 at 11:56
*analogue - Brody_Dickins commented on July 9th 19 at 11:59
:
fasthttp only reduces the load on the server
and that is the exchange of information over http.

however, if you plugging via http, it is a natural means elsewhere in your system (for example, when working with databases) you will be orders of magnitude greater plugging.

and you will not be useful features fasthttp until you live on a single server. or until your server is not comparable with the authors fasthttp server. they have a server with a huge amount of RAM.

so, you still will not be able to utilize fasthttp in full growth and already lose the ability to use the achievements of the community by net/http. - Katlynn_Ha commented on July 9th 19 at 12:02
: Well there's QUIC. There is even implementation for Go.
It is like http on steroids on the basis of UDP.

I think that there should be such things without any reference to http. - Katlynn_Ha commented on July 9th 19 at 12:05
:
> upd will be slower to work so skipped the delivery of packages.
> and the us arranged anologii tcp I definitely don't want to do.

Will not.
No one bothers to re-send the packet without waiting for a reply.
If you measure the average delivery time of packets and receiving responses
and send insurance packages takes, for example, to achieve 80% of the time. - Katlynn_Ha commented on July 9th 19 at 12:08
: I'm a noob in this. Sorry. - Brody_Dickins commented on July 9th 19 at 12:11
:
fasthttp is based on the standard http is inefficient, and its task is to reduce the load on the server, and not to increase the speed of delivery. - Katlynn_Ha commented on July 9th 19 at 12:14
that is, fasthttp refuses net/http gonogo.
but I have to use a standard network Protocol http. which is text-based, verbose and inefficient for speed. - Katlynn_Ha commented on July 9th 19 at 12:17
July 9th 19 at 10:40
websocket is only if you need compatibility in https.

If network:

gRPC if you need protection.
Or just Google Protobuf is very quick.
msgpack is a type of protobuf, but without the need to describe the Protocol, it is like a binary json.

There are still gotalk

If all on the same physical computer, then unix sockets.

The term "real time" means is quite different.
websocket is not a priori to be in "real time" as it is the network Protocol.

Find more questions by tags GoSockets