Why would I be getting `Error: write EPROTO` when making an HTTPS request in an Electron app?

I've been pounding my head against the wall for days on this so I am turning to the smart folks at Stackoverflow to help. Here's the deal:

System Details

  • Node Version (can't be changed due to Electron dependencies): v4.1.1
  • Electron Version: v0.34.3
  • OS Version: Mac OSX Yosemite 10.10.5 (14F1021)

Issue Description

I'm building an Electron app that has to communicate with my company's application server. The server connection has to go over HTTPS. I'm using Node's built-in https module. When making a request to the server I'm getting the following error:

{ [Error: write EPROTO] code: 'EPROTO', errno: 'EPROTO', syscall: 'write', address: undefined }

I've done a ton of Googling on this and most everything I've found points to proxies but I'm not using a proxy. I've tried the following:

  • Setting rejectUnauthorized: false in the options hash
  • Modifying the secureProtocol option (no results)
  • Attempting to set the --tls-cipher-list (no idea what I'm doing there)

I can make the request over curl without issue. Unfortunately, I can't post the actual URL I'm making requests to.

Sample Code

Here's some sample code (Coffeescript) that illustrates the issue:

https = require 'https' options = { host: '[Application URL]' path: '/' method: 'GET' port: 443 } options.agent = new https.Agent(options) callback = (response) -> str = '' console.log response console.log "STATUS: #{response.statusCode}" console.log "HEADERS: #{JSON.stringify(response.headers)}" response.setEncoding 'utf-8' response.on 'data', (chunk) -> str += chunk response.on 'end', -> console.log str makeRequest = -> req = https.request options, callback req.on 'error', (err) -> console.log err req.end() makeRequest() 

Does anyone have any idea what could be causing this issue? Is it a Node issue or something with the configuration of the application server? This bug is killing me and preventing me from hitting a milestone at work so any help would be greatly appreciated. Thanks!

4

1 Answer

To resolve this issue you are required to set https-proxy, which can be done with the following command:

npm config set https-proxy 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like