I'm trying to make a gRPC connection to a server. In my client code (go version: go1.13 darwin/amd64), I have
conn, err = grpc.DialContext(ctx, c.tiProxyURL, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithBackoffMaxDelay(10*time.Second))
This blocks the code as the connection is for some reason not established. Is there any way to debug this further and figure out what is the issue with the connection?
The connection is established when I'm running the server code on my local machine, but is blocked when trying to connect to a service deployed in the cloud through the ingress URL.
Related
I am trying to build a bittorrent client. I wrote this function to verify that I can establish connection to send messages to other peers but its not working.
func handShake(torrent *gotorrentparser.Torrent, peer Peer, peedId []byte) {
conn,err := net.Dial("tcp", peer.ip + ":" + strconv.Itoa(int(peer.port)))
if err != nil {
panic(err)
}
defer conn.Close()
}
Here peer is a struct of string ip and uint16 port.
Getting the following error:
panic: dial tcp 152.57.73.47:27569: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Couldn't find any similar issues. I tried to fix my local port address to be same as what I used to send the announce request but that didn't work either.
Edit: I tried with a different torrent, it is failing for some peers, but now it is working for some other peers. Is the issue only when the peer is using utorrent as bittorrent clients?
If you're developing a bittorrent client you should start with a more reproducable setup such as running an existing client with a known infohash on your local machine and then connecting to that (without using a tracker). Once you got that to work you can work on a tracker client implementation and then put those pieces together.
The internet is unreliable and bittorrent consists of many moving parts, so a single connection failure won't tell you much, you'll have to ensure that each part works properly and try with torrents that you have tested in an existing client to narrow down the cause of problems.
After few days here is the problem that I found.
Not all peers are able to accept an inbound request as they are behind a NAT.
Even when I hosted a torrent from one of my computer and tried to download through another system, I couldn't download as there was no reply from the peer for the SYN message being sent.
I was only able to download, when both the clients were on the same network and local peer discovery was enabled, and the TCP connection was also build with the local IP address.
I have done a setup of a three node Cassandra cluster. This one is on aws, and the server port are open. The three servers are well connected to each other and work perfectly.
I have set
authenticator: AllowAllAuthenticator
in my cassandra.yaml file
I would like to make the connection with go cql, here is the connection code
cluster := gocql.NewCluster("x.xxx.xxx.xxx")
cluster.Keyspace = "keyspace_name"
cluster.Consistency = gocql.Quorum
cluster.ProtoVersion = 4
cluster.ConnectTimeout = time.Second * 10
session, err := cluster.CreateSession()
if err != nil {
fmt.Println(err)
}
but go cql sends me back this message.
2020/09/26 09:53:44 gocql: unable to dial control conn x.xxx.xxx: dial tcp 127.0.0.1:9042: connectex: No connections could be made because the target machine actively refused them.
2020/09/26 09:53:44 gocql: unable to create session: control: unable to connect to initial hosts: dial tcp x.xxx.xxx.xxx:9042: connectex: No connections could be made because the target machine actively refused them.
panic: runtime error: invalid memory address or nil pointer dereference
There's a good chance that you're using the private IP address in your app to connect to the nodes but those are not accessible remotely because by definition, they are private addresses.
You need to make sure that you've configured your nodes to use:
listen_address: <ec2_private_ip>
rpc_address: <ec2_public_ip>
Nodes communicate with each other using the listen_address whereas clients connect to the cluster using the rpc_address which is why it needs to be configured with the publicly-accessible IP addresses of the EC2 instances.
Once you've got the nodes configured correctly, configure your app to use the public IPs as contact points in:
cluster := gocql.NewCluster("public_ip1,public_ip2,...")
This should allow your app to connect to the cluster. Cheers!
I am using Redigo to connect to redis server through golang.
redisConnection, err = redis.Dial("tcp", "...")
redisConnection.Do(..., ...)
If I restart my server, I am unable to execute any command using the same redisConnection. Shouldn't it reconnect when I execute Do again?
No, your assumption is not correct. Using the Dial function it returns a single connection when the server terminates the connection, the client is not able to reconnect.
You should use redis.Pool and it should be able to auto-reconnect when you ask for a new connection, the function is: pool.Get()
redisConnection.Err() returns a non nil value if the connection is not usable. We can Dial again in that case.
I am trying to communicate with a device (connected using ethernet) using TCP/IP connection. When a connection request is sent, I am getting an error:
dial tcp 192.168.137.10:502: connectex: A connection attempt failed because
the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to respond
But if I am connecting to the simulator (which will act as device), it is getting connected and sending me response.
I am using GO for coding. This is my code to connect to device
conn, err := net.Dial("tcp", "192.168.137.10:502")
if err != nil {
return nil, err
} else {
return conn, nil
}
Hardware Info:
Windows 10, 64 bit machine
PLC device connected over TCP/IP
I suspect that there is a problem with the server and not your client code. The fact that you aren't just getting a "connection refused" error tells me that the remote port is probably open. Chances are that the server is not performing an accept() on the incoming connection within a reasonable time.
Things that might cause this
Maximum number of connection configured on the server has been exceeded or the service is too busy.
Server has crashed
Funny firewall or another routing issue between you and the server. Some deep packet inspection firewalls sometimes cause these types of issues.
I suggest you try and do troubleshooting on the server side.
I try to use the slack-sample bot from this blogpost https://www.opsdash.com/blog/slack-bot-in-golang.html . I've successfully created my api token, but i can not connect to the websocket server (the rtm.start request passs normally). I've get the error message
dial tcp 54.242.95.213:443: connectex: No connection could be made because the target machine actively refused it
I've also tried to connect via a chrome app called Simple Web Socket Client and via a website based one tester. Both work well, i can establish a connection and i can send data.
I'm behind a proxy, but i only have troubles with golang's websocket.Dial function.
Does anybody know why this can happen?
I use:
- Windows 7 SP1 x64
- Golang 1.7.1 windows/amd64
Greetings
Tonka
If you are using gorilla/websocket, it has the ability to use a Proxy. From issue 107:
import "net/http"
...
var dialer = websocket.Dialer{
Proxy: http.ProxyFromEnvironment,
}
If you are using golang.org/x/net you should switch to gorilla/websocket.