Go Azure Function is throwing 504 gateway error when i hit from POSTMAN or Azure Code + Test

raviteja aketi 45 Reputation points
2024-02-23T18:36:23.99+00:00
Full Exception : Exception while executing function /Functions.FunctionTwo ---> System.Net.Http.HttpRequestException  /Connection refused (127.0.0.1:41435) ---> System.Net.Sockets.SocketException  /Connection refused    System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error,CancellationToken cancellationToken)    System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)    async System.Net.Sockets.Socket.
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2024-02-27T04:55:07.6266667+00:00

    @raviteja aketi I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution in case you'd like to "Accept" the answer.

    Issue:

    You were getting below error for your Go language azure function where you were trying to hit the endpoint from postman or testing it from azure portal function app code+test blade.

    Full Exception : Exception while executing function /Functions.FunctionTwo ---> System.Net.Http.HttpRequestException /Connection refused (127.0.0.1:41435) ---> System.Net.Sockets.SocketException /Connection refused System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error,CancellationToken cancellationToken) System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) async System.Net.Sockets.Socket.

    Solution:

    You found the previous discussion here and found the root cause of the issue. You were building the binary and uploading the zip file manually by using az commands from my your mac machibe but your chosen server was Linux. You found that you should build it for Linux environment. For example GOOS=linux GOARCH=amd64 go build handler.go

    Thank you again for your time and patience throughout this issue.


2 additional answers

Sort by: Most helpful
  1. raviteja aketi 45 Reputation points
    2024-02-25T16:54:18.97+00:00

    Check here once.
    https://learn.microsoft.com/en-us/answers/questions/1180861/httpclient-error-an-attempt-was-made-to-access-a-s

    I found the reason for the raised issue. I was building the binary and uploading the zip file manually by using az commands from my mac. But my choosen server is linux. I should build it for linux environment. For example GOOS=linux GOARCH=amd64 go build handler.go

    1 person found this answer helpful.
    0 comments No comments

  2. Dronec 181 Reputation points
    2024-02-24T04:02:03.6833333+00:00

    Looks like your quotation marks aren't closed on line 11


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.