temporalio / sdk-go

Temporal Go SDK
https://docs.temporal.io/application-development?lang=go
MIT License
528 stars 210 forks source link

After upgrading to 1.27.0 we get a context deadline exceeded #1550

Closed donchev7 closed 3 months ago

donchev7 commented 3 months ago

Expected Behavior

Be able to connect to temporal server

Actual Behavior

2024/07/17 14:00:20 Unable to create client failed reaching server: context deadline exceeded

Steps to Reproduce the Problem

  1. temporal server start-dev
  2. Run this main.go file with go run main.go
    
    package main

import ( "context" "fmt" "log" "time"

"github.com/pborman/uuid"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/workflow"

)

type Activities struct { Name string Greeting string }

// GetGreeting Activity. func (a *Activities) GetGreeting() (string, error) { return a.Greeting, nil }

// @@@SNIPEND

// GetName Activity. func (a *Activities) GetName() (string, error) { return a.Name, nil }

func GreetingSample(ctx workflow.Context) (string, error) { logger := workflow.GetLogger(ctx)

ao := workflow.ActivityOptions{
    StartToCloseTimeout: 10 * time.Second,
}
ctx = workflow.WithActivityOptions(ctx, ao)

// @@@SNIPSTART samples-go-dependency-sharing-workflow
var a *Activities // use a nil struct pointer to call activities that are part of a structure

var greetResult string
err := workflow.ExecuteActivity(ctx, a.GetGreeting).Get(ctx, &greetResult)
if err != nil {
    logger.Error("Get greeting failed.", "Error", err)
    return "", err
}
// @@@SNIPEND

// Get Name.
var nameResult string
err = workflow.ExecuteActivity(ctx, a.GetName).Get(ctx, &nameResult)
if err != nil {
    logger.Error("Get name failed.", "Error", err)
    return "", err
}

// Say Greeting.
var sayResult string
err = workflow.ExecuteActivity(ctx, a.SayGreeting, greetResult, nameResult).Get(ctx, &sayResult)
if err != nil {
    logger.Error("Marshalling failed with error.", "Error", err)
    return "", err
}

logger.Info("GreetingSample completed.", "Result", sayResult)
return sayResult, nil

}

// SayGreeting Activity. func (a *Activities) SayGreeting(greeting string, name string) (string, error) { result := fmt.Sprintf("Greeting: %s %s!\n", greeting, name) return result, nil }

func main() { // The client is a heavyweight object that should be created once per process. c, err := client.Dial(client.Options{ HostPort: client.DefaultHostPort, }) if err != nil { log.Fatalln("Unable to create client", err) } defer c.Close()

workflowOptions := client.StartWorkflowOptions{
    ID:        "greetings_" + uuid.New(),
    TaskQueue: "greetings",
}

we, err := c.ExecuteWorkflow(context.Background(), workflowOptions, GreetingSample)
if err != nil {
    log.Fatalln("Unable to execute workflow", err)
}
log.Println("Started workflow", "WorkflowID", we.GetID(), "RunID", we.GetRunID())

// Synchronously wait for the workflow completion.
var result string
err = we.Get(context.Background(), &result)
if err != nil {
    log.Fatalln("Unable get workflow result", err)
}
log.Println("Workflow result:", result)

}


  1. go run main.go
2024/07/17 14:02:06 INFO  No logger configured for temporal client. Created default one.
2024/07/17 14:02:11 Unable to create client failed reaching server: context deadline exceeded
exit status 1

If I change in go.mod the sdk version from:
    go.temporal.io/sdk v1.27.0

to

    go.temporal.io/sdk v1.26.1

everything works:

➜ go run main.go 2024/07/17 14:04:16 INFO No logger configured for temporal client. Created default one. 2024/07/17 14:04:16 Started workflow WorkflowID greetings_dcf4cf08-cb31-4460-ac0d-cddb7e2f164d RunID 2f4a0e00-7fa9-4bb2-bd64-5f12473cc5c8



## Specifications

  - Version: goSDK: 1.27.0 go version go1.22.5 darwin/arm64
  - Platform: Mac
Quinn-With-Two-Ns commented 3 months ago

On Mac with the same Go Version I am not able to reproduce this at least with

temporal --version
temporal version 0.13.2 (server 1.24.1) (ui 2.28.0)

My only idea would be something interfering with resolving localhost. Could try using the IP of your server or try passthrough:///localhost:7233?

donchev7 commented 3 months ago

do you mind trying with:

temporal --version
temporal version 0.13.1 (server 1.24.1) (ui 2.27.3)
Quinn-With-Two-Ns commented 3 months ago

No issue with temporal version 0.13.1

donchev7 commented 3 months ago

You were right. Now at my hotel I can't reproduce the issue. It must have been a networking issue at the client. Closing for now.

Thank you.