[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Brian Candler
Great - glad it's solved. I was only going to suggest you insert more logging calls all over the place until you find the problem :-) On Sunday, 21 March 2021 at 13:45:16 UTC Van Fury wrote: > > Hi, > > I have found the problem to the double PUT message being sent and have > solve it. > Thanks

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Van Fury
Hi, I have found the problem to the double PUT message being sent and have solve it. Thanks for the help. A lot of lesson learnt from this exercise. On Sunday, March 21, 2021 at 1:47:07 PM UTC+2 Brian Candler wrote: > On Sunday, 21 March 2021 at 11:42:37 UTC Brian Candler wrote: > >> Also: so

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Van Fury
Hi, Line line 147 of register.go is status code check in the second for loop but now solved. if res.StatusCode != http.StatusNoContent { But i still could not find out why the SendNFInstanceRegistration() message is send twice even though i have check the responses here fmt.Print("sta

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Brian Candler
On Sunday, 21 March 2021 at 11:42:37 UTC Brian Candler wrote: > Also: somebody has to be responsible for closing the response. You're not > explicitly returning an error from SendNFInstanceRegistration() to > HandleNFInstanceRegistration(), so the only way you can indicate that the > body is i

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Brian Candler
On Sunday, 21 March 2021 at 11:20:40 UTC Van Fury wrote: > After this , the PATCH message is send OK but when server B stop running, > server A break, complain g about the status check in the PATCH for loop > > status204ERRO[0350] Patch " > http://127.0.0.1:9090/nnrf-nfm/v1/nf-instances/6ba7b810-9

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Brian Candler
On Saturday, 20 March 2021 at 19:19:53 UTC Van Fury wrote: > OK, if I understand you correctly, the outer for loop is not needed and > that > there should be two for loops. > the first for loop does step 1,2 and 3 and then "break" out of the loop > when valid response is received > and then set

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Van Fury
Hi, This is what i have done so far but still having problems. When server A starts and server B is not available, it retry but if server B start running, sever A sends the PUT message in the SendNFInstanceRegistration(). When i print the status code in SendNFInstanceRegistration() i get stat

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-20 Thread Van Fury
OK, if I understand you correctly, the outer for loop is not needed and that there should be two for loops. the first for loop does step 1,2 and 3 and then "break" out of the loop when valid response is received and then set the "interval". The second for loop start a for _ := range ticker.C loop

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-20 Thread Van Fury
Hi Brian, Thanks for the reply. I intentionally left the error checks out so as to make the code short. Also using the Client.Do was an error and its suppose to be transport.Client.Do. Also in the main() does other stuff after the PUT and PATCH messages but does not have any function that is

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-20 Thread Brian Candler
On Saturday, 20 March 2021 at 10:04:33 UTC Brian Candler wrote: > 2. In HandlePUTMessage you are ignoring the HTTP status code > My mistake, ignore that one. You are handling it in the caller, SendPUTMessageToServerB. -- You received this message because you are subscribed to the Google Group

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-20 Thread Brian Candler
One other minor point. When you write for _ = range ticker.C { ... } then you have a timer leak if you break or return from that loop but don't call ticker.Stop(). If you only ever exit by "return" from the function, then you can simply do: ticker := time.

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-20 Thread Brian Candler
*> Any help and comments about my application design* A few general observations first: 1. In several places you are ignoring the error status, in particular at json.Unmarshal(bodybytes, &nfp) and the error from transport.Client.Do 2. In HandlePUTMessage you are ignoring the HTTP status code 3.