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

Getting error while calling from App engine #57

Open
nagaraja-sv opened this issue Aug 21, 2018 · 2 comments
Open

Getting error while calling from App engine #57

nagaraja-sv opened this issue Aug 21, 2018 · 2 comments

Comments

@nagaraja-sv
Copy link

nagaraja-sv commented Aug 21, 2018

Hi,

Can you please help to solve this
I am trying to call below function on Google AppEngine development server and getting the error.
But without appengine getting the record details from salesforce.

func init() {
	// Init the force
	forceApi, err := force.Create(
		"v39.0",
		"****************************************",
		"*******",
		"****@*****.com",
		"******",
		"*******",
		"production",
	)
	if err != nil {
		log.Fatal(err)
	}

	// Get somCustomSObject by ID
	someCustomSObject := &SomeCustomSObject{}

	err = forceApi.GetSObject("a0K0I00000DlwBQ", nil, someCustomSObject)
	if err != nil {
		fmt.Println(err)
	}

	fmt.Printf("%#v", someCustomSObject)

I am getting below error

the runtime process for the instance running on port 57472 has unexpectedly quit

2018/08/21 15:16:24 Error sending authentication request: Post https://login.salesforce.com/services/oauth2/token: http.DefaultTransport and http.DefaultClient are not available in App Engine. See https://cloud.google.com/appengine/docs/go/urlfetch/

@nagaraja-sv nagaraja-sv changed the title Geeting error while calling form App engine Getting error while calling form App engine Aug 21, 2018
@nimajalali
Copy link
Owner

App Engine Standard requires you to use the URL Fetch service to make HTTP requests. https://cloud.google.com/appengine/docs/standard/go/issue-requests

Unfortunately go-force doesn't support swapping out the Default HTTP Transport.

The easiest way to get around this would be to use App Engine Flexible which allows for the Default HTTP Client.

Alternatively some work was done by @jjordan to support setting your own http client in #39. However this will only set the http client globally and can/will run into race conditions if used in app engine for each request.

ctx := appengine.NewContext(r)
client := urlfetch.Client(ctx)
force.HttpClient = client

Ideally go-force would have a construct to set the HTTP Client per instance of go-force as outlined in #44, unfortunately I don't have the time to do this right now. PR's are always welcome.

@nimajalali nimajalali changed the title Getting error while calling form App engine Getting error while calling from App engine Aug 26, 2018
@nimajalali
Copy link
Owner

@nagaraja-sv Good news! With the new go111 runtime on App Engine Standard you should be able to do this.

https://blog.golang.org/appengine-go111

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

2 participants