Golang websocket client [closed] - go

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I want to make client websocket connections to exertnal server each connection = goroutine and reader. I was looking informations on the internet but I found how to create server websocket tutorials.
Can anyone be so kind and make a trivial example and walk me through. I am using standart golang libary https://golang.org/x/net/websocket.
I created some code but when I closed one connection program exited with EOF information. I won't post the code because it's probably bad duo to the fact it was my first try.
I know how to read/send message from websocket but I don't know how to create multiple connections.
Any informations, examples would be appreciate, thanks for reading

You can use the Gorilla WebSocket library
Here's an example of it's use as a client

Golang official doc recommends to use gorilla for building websocket based application. Still the problem is, gorilla websocket is not event based. Applications need to handle concurrent read and write operations. Developers need to write custom goroutines for handling connect, disconnect and read events.
I think it is better to have a library handling everything for you.
So, I decided to write down my own client implementation - gowebsocket on top of gorilla. You can find more detailed explaination here Getting started with websocket client in go

You can check the comparison given on this link.
https://yalantis.com/uploads/ckeditor/pictures/4265/websocket-libraries.png
Article suggests to go for Gobwas(https://github.com/gobwas/ws). Its best performance wise and offers all the required features needed for websockets related applications.

Related

Is there a library to work with this files in golang? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed last month.
Improve this question
I was looking for information about .sock files and what is the unix: at the beginning of this type of file. For example in the nginx configuration files you can find this:
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
And according to what I found on the internet they are called unix pipes, if I'm wrong please correct me, now that I've explained what I mean. Is there a library in golang to deal with this kind of files? I've been searching the internet and found very little information about it. Or is it possible to handle this kind of files in golang? It would be a good idea?
"unix domain socket" is not a file format, it is a construct handled by your system.
You interact with them much like you would interact with a tcp socket :
a server can listen on it (using net.Listen("unix", ...)),
a client can connect to it (using net.Dial("unix", ...)),
and then both can exchange messages using Read/Write.
See this question for a basic example of how to use them.
The format of the messages exchanged over this socket is hinted at by the fastcgi_pass part of your config line : fastcgi is a network protocol (wikipedia link) which describes how requests and responses should be exchanged.
Look for a golang library for "fastcgi server" or "fastcgi client" (I couldn't make out what side you are looking for from your question, I guess it would be a client ?).

WebSocket compatibility with GopherJS [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Looking for some general guidance on how to implement a WebSocket client in a way that works on both native Go execution platforms and through GopherJS.
It appears that GopherJS has two WebSocket libraries, one at gopherjs/websocket and one at goxjs/websocket. It seems that goxjs/websocket is "isomorphic", meaning it should work in GopherJS while remaining API-compatible with golang.org/x/net/websocket. That would provide compatibility in both execution environments, which is fine, but I'm not sure if it's the best solution. gopherjs/websocket doesn't appear to work outside of the browser execution environment, so it's a non-starter.
The most recommended WebSocket implementation for native Go apps seems to be gorilla/websocket at the moment. I'd like to use this as it seems to have a good API and it seems rather fully-featured. I can successfully run gopherjs build if I import gorilla/websocket, but I'm concerned that it will fail in the JavaScript environment, or that it will be compiled down into JavaScript that doesn't use the browser's implementation of the WebSocket API.
I'm not seeing much guidance on which library is appropriate for which scenario, so hoping this can help compare and contrast and provide the direction necessary to make a good choice.
I don't have any guidance on what you should do, but can share these facts:
The gorilla/websocket package is an implementation of the Websocket protocol on TCP connections. Because browser applications cannot access TCP connections directly, the gorilla/websocket package will not run in the browser.
There's a difference in the models presented by gorilla/websocket package and the gopherjs/websocket packages. The WebSocket protocol is message-based and the gorilla/websocket package exposes an API around messages. The gopherjs/websocket provides bindings that make the message-based WebSocket protocol look like a stream of bytes. Messages are not exposed in the gopherjs/websocket API.
The x/net/websocket package is all but abandoned. There are long standing issues with protocol compliance that have not been addressed.

ruby: libraries, frameworks, servers providing concurrency for development of a web based chat [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
What ruby concurrency lib/framework should I use for the development of a web based chat?
I have read about Eventmachine and Celluloid libraries, and about Sinatra::Synchrony, Cramp, Goliath and Gserver concurrency-ready-servers. If I am getting this right, all these libs or servers implement concurrency using two main different approaches: the reactor pattern (mostly all of them), or the use of multithreading (i.e. gserver, ...).
Now if this is all correct, and I hope it is, could someone:
correct me if it is not...
point out other actively developed libraries or frameworks that I've missed ?
The reason I am asking this is that I am trying to build, for learning purposes, a web based chat using ruby on server side. It will interact with client using websockets or Server Side Events, with Jquery or something else.
Also I've read about using ruby with a Xmpp server, or pub/sub messaging system (like Faye). If I put one of these in the dish, am I correct if I say if that it all shrinks down to having to worry only about making requests to those servers in a non-blocking way, rather than having to set-up a complete "non-blocking" ruby chat server ?
I know this is a bit convoluted, but I hope it still make sense..
But in case I am going totally the wrong direction about something, can someone please give me at least a general, vague idea of what I need to understand better ?
Thanks!
Funny you should ask. Peter Cooper from Ruby Weekly mentioned (Issue 116 - October 25, 2012) a talk subtitled "Ruby developers need to stop using EventMachine. It's the wrong direction," which spawned some interesting debate on HN, since many frameworks are built on top of it (Goliath, Cramp, etc.)
The disenchanted flock either to Celluloid (with Sidekiq as its most famous client), to the Node.js platform or to other languages that offer solid concurrency primitives from the get go. Yes, Go, Erlang, Clojure...
Personally, I implemented a realtime web-based chat not long ago using Cramp, Redis Pub/Sub and Websockets, loosely adapted from the following demo code. It worked as advertised, but the traffic it gets doesn't compare to the requirements of some high volume systems elsewhere.

Graphical HTTP client for windows [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am looking for a Windows graphical utility for performing HTTP operations.
For example, I want to be able to say things like:
POST to http://example.org/test/service
With a POST body: "Data goes here"
Does anyone know a good piece of software for doing this?
I too have been frustrated by the lack of good graphical http clients available for Windows. So over the past couple years I've been developing one myself: I'm Only Resting, "a feature-rich WinForms-based HTTP client." It's open source (Apache License, Version 2.0) with freely available downloads.
It currently has fairly complete coverage of HTTP features except for file uploads, and it provides a very good user interface with great request and response management.
Here's a screenshot:
Update: For people that still come across this, Postman is your best bet now: https://www.getpostman.com/apps
RestClient is my favorite. It's Java based. I think it should meet your needs quite nicely. I particularly like the Auth suppport.
https://github.com/wiztools/rest-client
Have you looked at Fiddler 2 from Microsoft?
http://www.fiddler2.com/fiddler2/
Allows you to generate most types of request for testing, including POST. It also supports capturing HTTP requests made by other applications and reusing those for testing.
You can use Microsoft's WFetch tool also. This is a good tool for all HTTP operations.
You could try Jsonium tool http://jsonium.org- nice free tool specialized on requests with JSON in bodies and responses
http://www.ieinspector.com/httpanalyzer/
http://www.microsoft.com/downloads/details.aspx?FamilyID=B134A806-D50E-4664-8348-DA5C17129210&displaylang=en
https://addons.mozilla.org/en-US/firefox/addon/9780/
http://soft-net.net/SendHTTPTool.aspx
https://addons.mozilla.org/en-US/firefox/addon/966/
Honestly, for simplistic stuff like that I typically whip up a quick HTML form in a local file and load that up in a browser.
I like rest-client a lot for the purposes you described. It's a Java application to test REST-based web services.
If anybody is still interest Eclipse Labs Rest Client tool is an excellent choice. I'm trying it in Windows in an EXE version and works smoothly.
I've worked also with Rest Client previously and its great too.
https://play.google.com/store/apps/details?id=com.snmba.restclient
works from Android Tablets & Phones. Flexible enough to try various combinations.

What HTTP traffic monitor would you recommend for Windows? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I need the sniffer to test network traffic of applications developed by me for Windows and Facebook.
Basic requirements:
display request and response
display HTTP headers
display the time it took to complete HTTP request
Now I'm using HTTP Analyzer.
A very good tool, but it terminates with some error after 10-15 min running on Vista.
Wireshark if you want to see everything going on in the network.
Fiddler if you want to just monitor HTTP/s traffic.
Live HTTP Headers if you're in Firefox and want a quick plugin just to see the headers.
Also FireBug can get you that information too and provides a nice interface when your working on a single page during development. I've used it to monitor AJAX transactions.
I now use CharlesProxy for development, but previously I have used Fiddler
Try Wireshark:
Wireshark is the world's foremost
network protocol analyzer, and is the
de facto (and often de jure) standard
across many industries and educational
institutions.
There is a bit of a learning curve but it is far and away the best tool available.
Microsoft Network Monitor (http://www.microsoft.com/downloads/details.aspx?FamilyID=983b941d-06cb-4658-b7f6-3088333d062f)
Fiddler is great when you are only interested in the http(s) side of the communications. It is also very useful when you are trying to inspect inside a https stream.
I like TcpCatcher because it is very simple to use and has a modern interface. It is provided as a jar file, you just download it and run it (no installation process). Also, it comes with a very useful "on the fly" packets modification features (debug mode).
I use Wireshark in most cases, but I have found Fiddler to be less of a hassle when dealing with encrypted data.

Resources