@@ -26,6 +26,7 @@ import (
2626 "context"
2727 "fmt"
2828 "io"
29+ "net"
2930 "strings"
3031
3132 "github.com/ansys/aali-sharedtypes/pkg/aaliflowkitgrpc"
@@ -430,6 +431,21 @@ func createClient(url string, apiKey string) (client aaliflowkitgrpc.ExternalFun
430431
431432 // Set up the gRPC dial options
432433 var opts []grpc.DialOption
434+
435+ // Add custom dialer with IPv4 first, fallback to IPv6
436+ opts = append (opts , grpc .WithContextDialer (func (ctx context.Context , addr string ) (net.Conn , error ) {
437+ d := & net.Dialer {}
438+
439+ // Try IPv4 first
440+ conn , err := d .DialContext (ctx , "tcp4" , addr )
441+ if err == nil {
442+ return conn , nil
443+ }
444+
445+ // Fall back to IPv6 if IPv4 fails
446+ return d .DialContext (ctx , "tcp6" , addr )
447+ }))
448+
433449 if scheme == "https" {
434450 // Set up a secure connection with default TLS config
435451 creds := credentials .NewTLS (nil )
@@ -447,7 +463,7 @@ func createClient(url string, apiKey string) (client aaliflowkitgrpc.ExternalFun
447463 // Set max message size to 1GB
448464 opts = append (opts , grpc .WithDefaultCallOptions (grpc .MaxCallRecvMsgSize (1024 * 1024 * 1024 )))
449465
450- // Set up a connection to the server.
466+ // Set up a connection to the server
451467 conn , err := grpc .NewClient (address , opts ... )
452468 if err != nil {
453469 return nil , nil , fmt .Errorf ("unable to connect to external function gRPC: %v" , err )
0 commit comments