Golang chat using udp problems - go

I'm developing a UDP chat using golang for my University work.
It's almost done, but I have some problems. When I run my server and try to connect to it the Server dont recognize a new connection, I need to press Enter twice to make it work. How can I resolve that ?
The source code is in: https://github.com/FranciscoJLucca/T1_LabRedes

Related

gRPC stopped working with APO on Windows 11

I have a Windows application (APP) and Audio Processing Object (APO) loaded by AudioDG.exe that communicate via gRPC:
APP part that is written in C# creates server via Grpc.Core.
APO part creates client via grpc++.
Server is on 127.0.0.1:20000 (I can see it's up and listening with netstat -ano).
I can confirm that APO is loaded into audio device graph by inspecting it with process explorer.
Everything worked like a charm on Windows 8 and 10, but on 11 it cannot communicate at all - I get either Error Code 14, Unavailable, failed to connect to all addresses or 4, Deadline Exceeded.
After enabling debug traces, I now see "socket is null" description for "connect failed" error:
I0207 16:20:59.916447 0 ..\..\..\src\core\ext\filters\client_channel\subchannel.cc:950: subchannel 000001D8B9B01E20 {address=ipv4:127.0.0.1:10000, args=grpc.client_channel_factory=0x1d8bb660460, grpc.default_authority=127.0.0.1:10000, grpc.internal.subchannel_pool=0x1d8b8c291b0, grpc.primary_user_agent=grpc-csharp/2.43.0 (.NET Framework 4.8.4470.0; CLR 4.0.30319.42000; net45; x64), grpc.resource_quota=0x1d8b8c28d90, grpc.server_uri=dns:///127.0.0.1:10000}: connect failed: {"created":"#1644240059.916000000","description":"socket is null","file":"..\..\..\src\core\lib\iomgr\tcp_client_windows.cc","file_line":112}
What I've tried so far:
Updating both parts to the latest grpc versions.
Using "no proxy", "Http2UnencryptedSupport" and other env variables.
Using "localhost" or "0.0.0.0" instead of "127.0.0.1".
Updating connection to use self signed SSL certificates (root CA, server cert + key, client cert + key).
Adding inbound / outbound rules for my port, and then disabling firewall completely.
Creating server on APO side and trying to connect with the client in APP.
Everything works (both insecure and SSL creds) if I create both client and server in C# part, but as soon as it's APP-APO communication it feels blocked or sandboxed.
What has been changed in Windows 11 that can "block" gRPC?
Thanks in advance!
In your input you write:
Server is at 127.0.0.1:20000
Further looking at the logs, you can see that:
The server is located at
grpc.server_uri=dns:///127.0.0.1:10000
Based on the question posed and the amount of data provided, I would check which port the server is really using and which port the client is looking for a connection on.
The easiest way to do this is to use the built-in Resource Monitor application. On the Network tab, in the TCP Connections list, you can find the application and the port it uses.
You can also use the PowerShell command
Test-NetConnection -Port 10000 -InformationLevel "Detailed"
Test-NetConnection -Port 20000 -InformationLevel "Detailed"
At least this is the first thing I would check based on what you described.
Regarding your question about the changes in Windows 11, I do not think that this is something that's causing problems for you. However, Windows 11 has additional security features compared to Windows 10, try disabling the security features completely as a test. Perhaps this will help solve the problem.
As for ASP.NET Core 6.0 itself (if I understood the version correctly), then there is a possibility that the server part, working not in the sandbox of the programming environment, still does not accept the client certificate. At the program level, you can try to fix this by adding the following exception to the code:
// This switch must be set before creating the GrpcChannel/HttpClient.
AppContext.SetSwitch(
"System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
// The port number(5000) must match the port of the gRPC server.
var channel = GrpcChannel.ForAddress("http://localhost:5000");
var client = new Greet.GreeterClient(channel);
More troubleshooting issues with ASP.NET Core 6.0 Microsoft described in detail here.
https://learn.microsoft.com/en-us/aspnet/core/grpc/troubleshoot?view=aspnetcore-6.0
I hope it was useful and at least one of the solutions I suggested will help solve your problem. In any case, if I had more information, I think I could help you more accurately.

having issues with/How to connect to MQTT broker in lambda function for alexa skill

The immediate issue I am trying to overcome is that my aws-lambda function is not connecting to my broke using the js MQTT library. I am able to use this library in a local node environment to connect, just not in the aws-lambda function.
I have created a zip file from this repo:
https://github.com/JordanKlaers/AlexaMQTT
That I uploaded to my lambda function. I am using the exported function from index.js.
Everything works well except for the part where it does not connect to the broker/client (line 83 in index.js)
When I run oldIndex.js from the repo I linked (which is just the promise function that connects, from the aws-lambda function) in my local node environment it connects and things run correctly.
I dont know how to create a minimum reproducible sketch because its success is based on interacting with hardware. I did create the "oldIndex.js" as a minimum sketch to show that at least the function to connect works. I have included logs of the lambda function to show that it works as expected up to the attempt to connect.
The only thing I can speculate would be some issue with my permissions for the role used with the lambda function but I have researched and added different policies to my role but that hasnt helped.
Here are the logs from the function when called (which shows that it gets to the promise and attempts to connect but doesnt succeed)
I had done almost everything myself, but got some final clarification on my approach from this tutorial so I not sure what else Im not considering/missing.
The main problem here is that your broker is running on a Pi attached to your local home network.
This means it is behind a Home Broadband Router which is performing Network Address Translation (NAT). This takes packets from your home network (10.0.0.0/24) and remaps them to have come from your public facing IP address.
This means that the Lambda code (running on AWS) can not directly send packets to the broker, so has no way to connect.
There are several possible solutions to this, but here are a couple.
Run a broker on a cloud hosting provider. You will be able to then reach this from anywhere.
Enable port forwarding on your router to expose port 1883 to the internet and forward any packets to the broker running on your raspberry pi. (This option depends on you having a fixed IP address or dynamic DNS)
For both of these you will probably want to enable authentication/authorisation on the broker and also probably add TLS.
You also need to look closer at the MQTT.js library and how to enable the error tracking so you can see why things fail e.g.
client.on('error', function(err) {...});

Golang `pions` lib example issue

I've just started experimenting with WebRTC with Go and downloaded pions/webrtc library but I'am stuck with it's data-channels example.
As it written in docs I opened jsfiddle client example.
Then I'am running go run main.go command in the /go/src/github.com/pions/webrtc/examples/data-channels folder on my server to launch data-channel.
After that I copy Browser base64 Session Description from jsfiddle example and paste it into my terminal where data-channels go script is running and it generates Golang base64 Session Description code which I paste into jsfiddle example and then press Sart session button.
And it fails to establish connection :(
This is my jsfiddle example for client side:
And this is my server side go script:
What am I doing wrong?
Thanks for using pion-WebRTC (I am one of the developers!)
WebRTC uses a technology called ICE to allow peers to talk to each other. Two peers exchange IP addresses via the SDP (the text you pasted) then they attempt to communicate by sending small UDP packets between each other. Once two IP addresses successfully communicate via ICE the rest of the WebRTC steps can continue. For you this process is failing. I don't know how/why though. Firewalls, VPNs etc... all can cause problems.
You will have to debug and check different scenarios. I would try running the examples on your local PC. If that works then maybe try between a different server. A good tool to help here also is tcpdump that can show if UDP packets are arriving. I usually use tcpdump -i any udp and inbound
We also recently added IPv6 support, so might be worth trying from master and see if that helps at all! Hopefully this helps, but if you are still having issues feel free to ask more questions. We are also all available via our Slack Channel you can sign up here here and would be more then happy to chat!
I met similar problem, and I solved by
echo $BROWSER_SDP | ./main
BROWSER_SDP is the session description in your browser, main is the exe by go build main.go(you can rename exe by mv). This can make sure transfer SDP to the server, which is really important.
The detail

Getting ICE failed in webrtc P2P video calling when communicating in different network

I'm working to create a video calling web app using WebRTC.
The communication is working fine on same network. But when communicating in different network I'm getting ICE failed error.
Error: ICE failed, see about:webrtc for more details
In about:webrtc I' able to get local and remote SDP's, but ICE State is failed. http://imgur.com/a/nPPDr
Here is the code of my main.js file
Here is the my log file from about:webrtc
P.S: Before posting the question I've checked several posts in SO and in other sites but no one did the trick.
Looking at the log file you provided it looks like you provided a TURN server, but the communication with that TURN server simply times out. So either something like a local firewall is blocking the communication with your TURN server or your TURN server is not working.
In case your local firewall blocks UDP traffic it might help to configure and use TURN TCP additionally to get through the firewall.
your about:webrtc does not show any relay candidates gathered from a TURN server. At the risk of sounding like a broken record: you need a TURN server for the majority of connections between different networks.

Indusoft Web Studio Error Messages?

Apologies if this is a pretty simple question, but I'm pretty new to IWS.
When ever I startup IWS (it's running on Microsoft Server that I remote desktop into) and enter my login details I get this message:
Failed to start TCP/IP Server, please check if the TCP port is already in use
During this same session I will also get the message below whenever I try to change tags in my trend sheets:
WARNING: Tag changes in any trend group will only take place in the next day history file.
It seems any changes I make in relation to tags and driver sheets are ignored and I want to know if this is related to the above error messages and how do I go about debugging/fixing this?
Note: I do not get these messages in other IWS sessions on other servers and I don't experience these problems.
Projects running the TCP/IP Server task use a TCP Port that is defined in the InduSoft Project Settings - Communication tab. By default, InduSoft uses port 1234. The error message you mention can occur if another process binds to that port before InduSoft has started the TCP/IP Server task.
Change the TCP Port. 1234 is the standard Port for Indusoft.
Try to Map your useds Ports before chosing some.
Or kill the process that are using the Port 1234, as explained in the link.
https://receitasdecodigo.com.br/java/listar-e-matar-processo-pela-porta-em-uso-no-windows-pelo-cmd

Resources