Mastering WebSockets With Go - An in-depth tutorial

preview_player
Показать описание
WebSockets is one of the oldest ways to communicate in a bi-directional way and is widely used today. It is supported by most browsers and is relatively easy to use. WebSockets are really useful when building real time apis.

In this tutorial, we will cover what WebSockets are and how they work, how to use them in Go to communicate between servers and clients. We will also explore some regular pitfalls that I've seen in WebSocket APIs, and how to solve them.

During the tutorial, we will be building a chat application where you can enter different chat rooms. The WebSocket server will be built using Go, and the client connecting in vanilla JavaScript. The patterns we learn and apply could easily be adapted when connecting using a Websocket Client written in Go, Java, React, or any other language.

We will learn about Authentication, Heartbeats using Ping & Pong, Cross Origin and a number of other useful WebSocket related things.

If you prefer a written format of the video instead you can visit my blog

00:00 Introduction
03:04 What are WebSockets
05:46 Project setup
18:46 Connecting Websocket
28:14 Adding Clients
33:46 Reading & Writing Messages
53:00 Events
01:12:24 HeartBeating
01:22:27 Jumbo Frames
01:24:36 Cross Origin
01:27:37 Authentication
01:55:10 TLS
02:02:18 Finalizing

Links mentioned in the article

Creative Commons Attribution-ShareAlike 3.0 Unported
Рекомендации по теме
Комментарии
Автор

Great time to watch the tutorial. Gorilla toolkit was archived for the past 8 months. But 2 days ago it became active again after new maintainers took over. No better time to watch this.

IvanRandomDude
Автор

Thank you! It's great. In two hours I've learned a lot. It's high quality course. I don't have much experience in coding, but I doubt I could have thought of some things on my own.

July-dhlk
Автор

I would like to thank you for this amazing, detailed tutorial. This is exactly what I'm looking for. You're a lifesaver.

MonsterGames
Автор

extremely well done and complete example, great job sir!

YandryPozo
Автор

thank you for this tutorial! I really appreciate that you invested your time to make this video.

paca
Автор

Hi I`m beginner in websockets and your video helped me to better undestand how to use gorilla building simple messengers.Your video is awesome!!

yegor
Автор

best golang ws chat tutorial, thanks a lot !!

dhaw
Автор

I think it's now like a sixth time I watch the "this is fairly fairly simple, I believe" part and finally I think I dare to move on. :D

tokintmash
Автор

This tutorial is awesome and explained so well - thanks

jaypatel
Автор

Wow, Thank you so much for sharing the amazing content, liked 👍 and subscribed

mahendranath
Автор

This is a great tutorial, thanks you!

PhilippeBazinet
Автор

Simply Fantastic, helps me a lot.i came here reading your medium post, Thanks a ton brother for the amazing content.
I have a question though...
I am building an Android game using kotlin in the front end and i am planning to choose Go at the backend and obviously I wil be using websockets, this video helped !!

bjugdbjk
Автор

Great tutorial! Looking forward your other tutorials!
Too bad that your mic isn’t great. I think your content is so good that I would gladly swish 30-50 kr towards a new microphone. :)

SvartAdamSolander
Автор

Awesome tutorial! I have one question, your pong/pong handling, from what I can tell its not doing anything if the client stops sending pongs back.

skl
Автор

Great video!
Micro from DDD video was definetly better btw

Flascoo
Автор

Oh man, the way you're using Go routines and methods and structs... Struggling to keep up with everything :D

tokintmash
Автор

Just what i was looking for, Thanks! is there a Part II? connecting to an external data storage (redis)?...

notnull
Автор

When we say that Gorilla 'Connections only support one concurrent reader and one concurrent writer', does this mean that for *each* client connection we can only have one goroutine reading messages and one gorountine writing messages via a channel? Obviously, if we have multiple clients, there will be an equivalent number of reading and writing goroutines - but I assume this is not what the restriction is referring to?

dfdkjr
Автор

Firstly Thanks and Nice explained !!
BTW I have one question, how do we handle the web socket connections in Distributed system (like multiple instance are running for the same service)

shubhamverma
Автор

This is absolutely amazing, thanks nigga !!!

mikealejandro