this is the best tutorial. thank you for posting. looking forward more gRPC apps
@TensorProgramming4 жыл бұрын
Glad you like the content.
@mukulrawat40955 жыл бұрын
Thanks Tensor for your great videos on Go. Would you be doing more videos on Go? I would love to see you build a bigger web app with docker and kubernetes. Regards.
@TensorProgramming5 жыл бұрын
Yes, we are moving toward kubernetes and larger apps with go.
@josebravo79985 жыл бұрын
@@TensorProgramming would be awesome!
@AbleBuilders3 жыл бұрын
Great work. It really makes a really good project in all cases.
@sachinmaurya32593 жыл бұрын
Question : After creating the docker file can we chat without using the client main.go file let's say I push this docker image on docker hub and if a random guy download this images then how can he/she run in his device? without using client main.go file
@otaxhu Жыл бұрын
I have a question, I have seen in other videos that websockets are used for this type of messaging applications, what is the difference between this application and one that was programmed using websockets?
@TensorProgramming Жыл бұрын
This application still uses websockets. gRPC is a encoding protocol more so then a transport protocol. You can think of it more like JSON than anything else. The idea is that its small and fast when compared to other encoding formats. But apart from that, there is no real difference.
@otaxhu Жыл бұрын
great work dude
@AshwaniSharma02074 жыл бұрын
You could use multi-stages in Dockerfile to further optimize the size of Docker image. As we don't need to Golang to run a binary, In the second stage we will just use the alpine image and run the binary generated in the first step.
@TensorProgramming4 жыл бұрын
Sure, but this is just an intro. Not going to jump into "advanced" concepts right off of the bat like that.
@AshwaniSharma02074 жыл бұрын
@@TensorProgramming oh , I see.
@AshwaniSharma02074 жыл бұрын
@@TensorProgramming Thank you for the video :)
@georgelza3 жыл бұрын
@@TensorProgramming think my why not copy binary into docker image falls under this advance options video, did you get to it, can you point me to it. get the idea I'm going to be spending some time here on your channel.
@TensorProgramming3 жыл бұрын
@@georgelza I have no idea what you are asking me here.
@sionlawrencehannuna45985 жыл бұрын
These videos are great. Thanks.
@barathv99104 жыл бұрын
Syntax error - can't find = in "on". Must be of the form: name=valuedockerfile-utils(33) i get this error in vscode in the line (GO111MODULE=on)
@TensorProgramming4 жыл бұрын
You need to enable the go modules if you are using an older version of go or you should just update your version of go to the latest version.
@barathv99104 жыл бұрын
@@TensorProgramming i removed the line still its working.
@obasootomichael61722 жыл бұрын
thanks for your reply, so have been working on attching a database to the application for weeks now, but seems am not gettting it. can you please give me an idea how i can make it work. thank you
@TensorProgramming2 жыл бұрын
What sort of database?
@obasootomichael61722 жыл бұрын
@@TensorProgramming postgresql or mongodb
@TensorProgramming2 жыл бұрын
@@obasootomichael6172 You'd want to add the write call into the BroadcastMessage call to store the message itself; get the message for one of the clients and put it into the database, then broadcast it out to the other clients. With most of the postgres drivers in Go you would also want to define how the message will look as a model and add postgres or json annotations to the fields to easily serialize/deserialize them back and forth. Then for reading the data, you would want to presumably do it when the connection is made in the CreateStream call. Basically just create the connection and then push the stored messages into it.
@obasootomichael61722 жыл бұрын
@@TensorProgramming thanks for your response, it really worked, thanks a lot.
@obasootomichael61722 жыл бұрын
@@TensorProgramming i still need your help on another project, maybe we can talk about it in private.
@kianostad50645 жыл бұрын
What about reconnecting? What's is the proper way to handle it? and also can you talk about GRPC load balancing in Go?
@TensorProgramming5 жыл бұрын
I may do something with load balancing when I get into kubernetes, since in those cases you have more then one server typically and you have to balance the loads between the two. This application doesn't have a great way to deal with re-connections, though that's fine since each time a client connects it creates a new connection and a new ID since its linked to the timestamp.
@georgelza3 жыл бұрын
@@TensorProgramming did you ever get to this ?
@mrzhou904 жыл бұрын
Awesome video! Qns pls - from 10:00 to 10:30, would it not suffice to just use "wait.Wait()" to block execution (and not creating a goroutine of course) ? ie: .... wait.Wait() return &proto.Close{},nil } sorry im very new to using the sync.WaitGroup{} here, so pls forgive me if it's a basic question.
@TensorProgramming4 жыл бұрын
Its better to just spawn a new go routine for the wait group wait call because it lets that operation happen asynchronously without blocking other goroutines that may not need to be blocked.
@petrostrak77373 жыл бұрын
Awesome, thanks a lot!
@raveheart585 жыл бұрын
Great tutorial thank you. Replacing my custom tcp protocol server in go with a grpc replacement. This is a great reference thank you very much! btw, which font are you using?
@TensorProgramming5 жыл бұрын
Fira code with Code ligatures enabled.
@vahidhasani40862 жыл бұрын
Thanks for your awesome video. Where can I find third-party protos?? and it will be great if you explain what are those?
@TensorProgramming2 жыл бұрын
There are some libs like this: github.com/googleapis/api-common-protos which might be helpful for getting common protos.
@barathv99104 жыл бұрын
"panic: dial tcp 127.0.0.1:3306: connect: connection refused" : i get this error when i run the docker server. iam unable to connect to the mysql server from docker server. but iam able to do it from my machine. i use ubuntu latest version.
@TensorProgramming4 жыл бұрын
You can't connect to localhost from Docker and expect to access the services provided by the host machine. There is functionality to connect to it via a special address but it would be better to just run a docker image with MySQL in it.
@georgelza3 жыл бұрын
some questions and a request. #1... would it not make more sense to build the go binary outside of docker, and then just copy it into the container ? #2... love the way you build the server. using go routines.. looking at refactoring mine. i understand as a chat app all messages that the server gets we want to broadcast to all.... any chance you might be willing to modify this "slightly" instead of broadcasting messages to all, just ping message back to the originator. I want to use this structure where "clients" can send data to a server, server will log it and just respond with a "ack yes got it" still noob so sticking examples together to get to my "teach myself Go" app to look/behave as I want.
@TensorProgramming3 жыл бұрын
1) no. the point of docker is that you can deploy code to the container and update it without taking it offline. Its not like the size of the docker container is an issue, most of these are pretty small. If you were to deploy a binary, you would have to remove the binary before you replace it or use some kind of update protocol and in that case, why even use a docker container? 2) You should attempt to do that yourself. Sticking to examples does help to some extent if you want to learn to program but at some point you should tinker with the code and see if you can get it to do things that maybe weren't in the original. Adding a ping/pong functionality to this chat app wouldn't be too difficult, if you use the information that I gave you in the video you should be able to do it. Just modify the broadcast message function to only send the outgoing message to a specific connection in the server. You could even add a bit of metadata to the server struct to indicate which user is the sender and which is the receiver. Next time you have a burring question, please just leave it in one comment, I always answer all of the comments on my videos.
@georgelza3 жыл бұрын
@@TensorProgramming sorry, posted this question first, then decided to read what the other comments was, leading to the other question. re #2. Already busy modifying my code. question. go, as the language stands is a modern language, so question, the standard gRPC server as per other examples on the web... is the server capable of multiple client connections, concurrently. Asking as you've example creates the array of connection objects, which by itself implies multiple connections being handled, which I've not seen done in other online examples. lastly, there are a couple of online Go based forum's, you have a fav ?
@TensorProgramming3 жыл бұрын
@@georgelza The basic structure of this app is to allow multiple clients to all connect to the server. If one posts a message it is broadcasted out to all of the other connected clients. There are more elegant ways to do this but this is the method that I used for this particular example. As for forums in Go, I simply don't frequent them enough to have a favorite. Personally, when I do research I mainly look at github, google, reddit or stack overflow.
@georgelza3 жыл бұрын
@@TensorProgramming got my app working direct in terminal, but the same client is crashing when connecting to the the dockerized server... scratching head. trying to fix this and implement the array of connections as per your app.
@TensorProgramming3 жыл бұрын
@@georgelza What kind of crashes are you seeing?
@sagarkapasi0994 жыл бұрын
Possibly A Noob Question: Using grpc is used to make calls internally right?. but if we build a chat application in the real world, then we should be using WebRTC (Or similar) right? with the added benefit of WebRTC being that it doesn't consume bandwidth?
@TensorProgramming4 жыл бұрын
RPCs can be used internally or externally, doesn't really matter. WebRTC is a transport protocol, where as gRPC is a pattern and encoding protocol. You can use gRPC with WebRTC or whatever else and its probably more likely that you would just use non specific web sockets rather than WebRTC unless you also want video.
@MlgTheUno5 жыл бұрын
Hey... Tensor... What is your opinion on Go VS elixir?!.. I heard the elexir is faster than Go..
@TensorProgramming5 жыл бұрын
It really depends on the use-case. Go is a faster language for smaller programs but Elixir has its virtual machine which allows it to be more robust and makes concurrency easier to deal with. Elixir will automatically assign its processes to the multiple cores on your machine where as in go you have to code it so that it will use go routines in that way. Again it will really depend on the use-case but I personally like Elixir more for various reasons.
@MlgTheUno5 жыл бұрын
@@TensorProgrammingi am currently working on a Uber like prototype app... With node for the backend, mostly because of the easy graphql support but I have a feeling that in a production environment, at some point, nodejs won't meet the requirements of the app... For this use case, what technology is the most suitable for the backend? ..
@TensorProgramming5 жыл бұрын
@@MlgTheUno Well, I can't really say based on just what you told me. If its about graphQL then both elixir and go are suitable choices. If its about scalability, then again both of these languages are good in their own way. Phoenix/Elixir might be easier for something like that simply because its more opinionated etc. If you've already got a working product in NodeJS, then perhaps it isn't worth switching until you know what type of services you need to focus on. Does your app have to deal with tons of volume? does it need to be real time? etc. They are working on some fantastic technologies for Phoenix and Elixir in the future which make it a very appealing choice. LiveViews for instance, are a game changing idea which I am looking forward to. The ability to just build everything in Elixir and not have to build a full client-side application is a very appealing proposition.
@MlgTheUno5 жыл бұрын
Thank you so much... With the help of ur opinion I will do some further reach on the 2 technologies... Your channel is helping me a lot... I mean a lot..
@TensorProgramming5 жыл бұрын
I am actually about to start a fairly comprehensive Elixir tutorial so perhaps that will also be of use. Anyhow, good luck.
@asdf79725 жыл бұрын
I should have known ur channel before!!!!!!
@TensorProgramming5 жыл бұрын
You can only learn about it when you do.
@srikanthg80064 жыл бұрын
Great video and easy to understand. One question. If i want to connect the client with UI, do i need to use REST API only?
@TensorProgramming4 жыл бұрын
You could build whatever kind of API you want. Could be a websocket RPC too.
@obasootomichael61722 жыл бұрын
Hi tensor, what a great video you did, but i'm getting this error "nil pointer dereference" from my client side, have been trying to solve it for days now😭😭,pls help me..
@TensorProgramming2 жыл бұрын
Its entirely possible that the system itself is not working because its been almost 4 years since this tutorial. That said, I cloned the repo and it worked out of the box. So I am not sure where you are getting a pointer error. You should check your code against the code in the repo.
@seanknowles53094 жыл бұрын
Bro what theme and font are you using, its awesome!
@TensorProgramming4 жыл бұрын
Spacemacs dark with Firacode Font + Code ligatures enabled.
@far_out_faris5 жыл бұрын
It's throwing "Error sending message: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [::1]:8080: connect: connection refused" from the client-side. Not when run the main file only after sending a message. Thoughts ?
@TensorProgramming5 жыл бұрын
Did you run docker with the -it -p 8080:8080 flags? If you can't access docker from the localhost then you will have to find the IP that it is using on your machine.
@far_out_faris5 жыл бұрын
@@TensorProgramming I did not. At 18:50 of the code-along you demo'd the client server interaction on your local machine prior to building the docker file. Thats what part I'm at and am trying to do the same. I should have been more specific in my original comment.
@TensorProgramming5 жыл бұрын
@Faris Huskovic Oh I see. What operating system are you using currently? I don't show it in the video but with windows you have a small little firewall box that should pop up to ask if you want to forward the port. Of course, if you don't forward the port, then you can't connect to the server. The error in general that you are highlighting is an error that is indicative of the client not being able to find the server. Make sure you are dialing into localhost:8080 without and backslashes or anything like that and make sure that the server is running prior to running the client. If you are still having issues, go ahead and clone the repository and see if you can get it to work without docker. If that works then perhaps you've got a small typo somewhere.
@far_out_faris5 жыл бұрын
@@TensorProgramming typo in my server file.....sigh. Thanks Tensor
@TensorProgramming5 жыл бұрын
@@far_out_faris Not a problem, happens to the best of us.
@armandiskandarsyah54145 жыл бұрын
Hi, Tensor. Thanks for making this video. what is "proto.Broadcast_CreateStreamServer" in dart? because, I want to make it one language in dart.
@TensorProgramming5 жыл бұрын
Just look in the BroadcastServer class that's generated and it'll be in there. It will probably have a similar name.
@armandiskandarsyah54145 жыл бұрын
@@TensorProgramming Thanks for reply, I have looked in pbgrpc.dart file, It's name BroadcastServiceBase. But it doesn't have the send method like in go language
@AllAboutCode4 жыл бұрын
Your name is tensor ?
@TensorProgramming4 жыл бұрын
Nope, its just a pseudonym.
@flipside-games4 жыл бұрын
Can you please make a video of actually deploying an rgpc service to the cloud and then connecting to it.
@TensorProgramming4 жыл бұрын
Maybe at some point. It really depends on the cloud service but the steps are more or less very easy to follow. Most of the platforms you would use provide their own tutorials and documentation.
@flipside-games4 жыл бұрын
@@TensorProgramming Specifically a tutorial on how to connect a webrpc client. Its not so simple, as it needs to get routed through envoy.
@user-ov5nd1fb7s4 жыл бұрын
I don't think that slice of connections is a great idea. What happens if you have people connecting and disconnecting? It seems like your slice will just keep growing with closed connections. And what happens if you have multiple client applications, thus CreateStream is called in parralel?
@TensorProgramming4 жыл бұрын
Its fine, the slice will grow and shrink accordingly. When you append values to a slice, it takes the old slice and puts all of its values into a new slice to accommodate for the new values. If I was worrying about thread safety though, I would likely wrap the connections in a mutex or use a channel instead. The Stream also helps with that.
@user-ov5nd1fb7s4 жыл бұрын
@@TensorProgramming I think about a map[int]*Connection with a mutex would be fine because you can have a static ID that you can refer to later delete closed connections. I don't know what you mean by "shrink accordingly". How does append() have a case where it shrinks the slice?
@TensorProgramming4 жыл бұрын
@@user-ov5nd1fb7s So append copies the data over to a new area in memory. In theory, if the slice is smaller and it gets copied over it would "shrink" because the GC would remove the empty slots. In practice, I believe the compiler makes a choice about whether or not it moves the memory; that said, it would eventually have to move it at some point and so it would eventually have to shrink the memory footprint if the slice is smaller. Yes a map would also work, and so would a generalized struct.
@user-ov5nd1fb7s4 жыл бұрын
@@TensorProgramming Ohh okay, i get it now. It's a tradeoff, i guess. On one hand, the slice is lighter than a map but on the other hand that method would create more work for the GC. It doesn't really matter until you have N > 1 million
@TensorProgramming4 жыл бұрын
@@user-ov5nd1fb7s Yeah, well part of it just had to do with the fact that this is an example and not a production app. In production, I probably wouldn't be using a slice and instead would use something more full featured. As you've pointed out, yes there wouldn't be any real problem until you start to reach more connections but at that point, you might as well design the system with concurrency in mind.
@swapnilnakade24024 жыл бұрын
Hey tensor.A lot of Love your videos! I am having an error on server side actually when i create a client and send the message it works fine but when i close that client and run the main.go file again on same terminal instance then a RPC error is shown on server side terminal Error with stream: &{%!s(*grpc.serverStream=&{0xc0002124b0 0xc000083800 0xc000242200 0xc0002143c0 {} 4194304 2147483647 false {0 0}})} - Error : rpc error: code = Unavailable desc = transport is closing What i am thinking of is i guess when i am closing that connection its still in the slice and causing the error on server side. still i am not sure about it. Can you please explain whats actually going on? cause i am not getting my head over it..Thank you!
@danielvega6466 ай бұрын
Stately!
@skd18605 жыл бұрын
Make a tutorial on building messaging app using flutter and without firebase
@TensorProgramming5 жыл бұрын
I've already done that multiple times.
@skd18605 жыл бұрын
Without using firebase
@TensorProgramming5 жыл бұрын
@@skd1860 Yes there are a few videos without firebase already on my channel. For instance, the Actix Rust backend was a chat app that has a front end in Flutter. That app does feature Firebase authentication but not firebase as a database for the chat messages. The messages are sent to and from the Rust API.
@daksh_sagar5 жыл бұрын
"Hey guys, my name is Tensor", is it actually Tensor ?
@TensorProgramming5 жыл бұрын
No its not actually tensor. That is the pseudonym that I use for my channel though. Mainly due to the work that I do in my day job, I have to keep my name a bit confidential. Some of the jobs that I do require clearance and legal red tape. Easier to just not give my name then to worry about whether or not I am violating any of those contracts.
@andibensisva21555 жыл бұрын
Tensor Programming Thank you sir. Youre the best. I hope you still updating Elixir and new Phoenix project.
@Lorenzo-cq6uo Жыл бұрын
Unlucky me... i think this video is become too old... and many of this functions are deprecated and are no longer genereted by protoc
@TensorProgramming Жыл бұрын
Yes, I am planning to refresh the go videos. gRPC is something that will be done eventually.