Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client can't get attachments which is set from server #2641

Open
2456868764 opened this issue Mar 22, 2024 · 5 comments
Open

client can't get attachments which is set from server #2641

2456868764 opened this issue Mar 22, 2024 · 5 comments

Comments

@2456868764
Copy link

Environment

  • Server: Dubbo-go, master
  • Client: Dubbo-go, master
  • Protocol: Triple
  • Registry: N/A

Issue description

server code

func (srv *GreetTripleServer) Greet(ctx context.Context, req *greet.GreetRequest) (*greet.GreetResponse, error) {
	resp := &greet.GreetResponse{Greeting: req.Name}
	ctx = context.WithValue(ctx, constant.AttachmentKey, map[string]interface{}{"server_info": "dubbo httpbin"})
	return resp, nil
}

client code

        ctx := context.Background()
	resp, err := svc.Greet(ctx, &greet.GreetRequest{Name: "hello world"})
	if err != nil {
		c.JSON(http.StatusBadGateway, err.Error())
		return
	}
	attachments := make(map[string]interface{})
	if ctx.Value(constant.AttachmentKey) != nil {
		attachments = ctx.Value(constant.AttachmentKey).(map[string]interface{})
	}

and found that client attachments is nil.
then use curl to simulate as http which return is follow:

(base) ➜  dubbo-go git:(feat-security) ✗ curl -v -H "content-type:application/json" http://127.0.0.1:8000/greet.GreetService/Greet -d '{"name":"hello"}'
*   Trying 127.0.0.1:8000...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> POST /greet.GreetService/Greet HTTP/1.1
> Host: 127.0.0.1:8000
> User-Agent: curl/8.1.2
> Accept: */*
> content-type:application/json
> Content-Length: 16
>
< HTTP/1.1 200 OK
< Accept-Encoding: gzip
< Content-Type: application/json
< Date: Fri, 22 Mar 2024 03:05:43 GMT
< Content-Length: 20
<
* Connection #0 to host 127.0.0.1 left intact
{"greeting":"hello"}%

no attachments return

Logs

Click me to check logs
Copy logs to here.
@YarBor
Copy link
Contributor

YarBor commented Mar 28, 2024

plz assign to me

YarBor pushed a commit to YarBor/dubbo-go that referenced this issue Mar 31, 2024
@Yan0613
Copy link

Yan0613 commented Apr 1, 2024

thx, I will fix it as soon as possible.

@YarBor
Copy link
Contributor

YarBor commented Apr 1, 2024

Hi @Yan0613 I was working on this issue and don't think two people need to work on this. : )
I have been discussing this with mentors for some time.
However, if you have a solution ready, please let me know. Thanks!

@Yan0613
Copy link

Yan0613 commented Apr 1, 2024

Hi @Yan0613 I was working on this issue and don't think two people need to work on this. : )
I have been discussing this with mentors for some time.
However, if you have a solution ready, please let me know. Thanks!

I see, but I think.that's no problem, I have also received this task😂

@YarBor
Copy link
Contributor

YarBor commented Apr 1, 2024

Hi @Yan0613 I was working on this issue and don't think two people need to work on this. : )您好,我正在研究这个问题,并且认为不需要两个人来解决这个问题。 :)
I have been discussing this with mentors for some time.我和导师讨论这个问题已经有一段时间了。
However, if you have a solution ready, please let me know. Thanks! 但是,如果您准备好解决方案,请告诉我。谢谢!

I see, but I think.that's no problem, I have also received this task😂明白了,不过我想,没问题,我也接到这个任务了😂

haha, But I think this appeal is reasonable and worth trying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants