Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

NetworkingError: Protocol "https:" not supported. Expected "http:" #127

Open
nathanjd opened this issue May 8, 2017 · 0 comments
Open

Comments

@nathanjd
Copy link

nathanjd commented May 8, 2017

I am trying to mock the responses from the AWS API as suggested by AWS support.

https://forums.aws.amazon.com/thread.jspa?threadID=135220

However I am finding this to be impossible due to the following error:

NetworkingError: Protocol "https:" not supported. Expected "http:"
      at new ClientRequest (_http_client.js:90:11)
      at node_modules/replay/lib/pass_through.js:29:20
      at node_modules/replay/lib/recorder.js:42:7
      at Function.layer [as next] (node_modules/replay/lib/chain.js:50:7)
      at node_modules/replay/lib/chain.js:51:85
      at node_modules/replay/lib/logger.js:17:5
      at Function.layer [as next] (node_modules/replay/lib/chain.js:50:7)
      at node_modules/replay/lib/chain.js:51:85
      at node_modules/replay/lib/pass_through.js:53:12
      at ProxyRequest.layer [as proxy] (node_modules/replay/lib/chain.js:50:7)
      at ProxyRequest.end (node_modules/replay/lib/proxy.js:128:10)
      at features.constructor.writeBody (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/http/node.js:130:14)
      at features.constructor.handleRequest (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/http/node.js:98:12)
      at executeSend (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/event_listeners.js:284:29)
      at Request.SEND (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/event_listeners.js:299:9)
      at Request.callListeners (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/sequential_executor.js:101:18)
      at Request.emit (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
      at Request.emit (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/request.js:673:14)
      at Request.transition (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/request.js:22:10)
      at AcceptorStateMachine.runTo (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/state_machine.js:14:12)
      at /Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/state_machine.js:26:10
      at Request.<anonymous> (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/request.js:38:9)
      at Request.<anonymous> (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/request.js:675:12)
      at Request.callListeners (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
      at callNextListener (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
      at /Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/event_listeners.js:207:9
      at finish (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/config.js:313:7)
      at /Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/config.js:331:9
      at SharedIniFileCredentials.get (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/credentials.js:126:7)
      at getAsyncCredentials (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/config.js:325:24)
      at Config.getCredentials (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/config.js:345:9)
      at Request.SIGN (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/event_listeners.js:179:22)
      at Request.callListeners (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/sequential_executor.js:101:18)
      at Request.emit (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
      at Request.emit (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/request.js:673:14)
      at Request.transition (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/request.js:22:10)
      at AcceptorStateMachine.runTo (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/state_machine.js:14:12)
      at /Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/state_machine.js:26:10
      at Request.<anonymous> (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/request.js:38:9)
      at Request.<anonymous> (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/request.js:675:12)
      at Request.callListeners (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
      at Timeout.callNextListener [as _onTimeout] (/Users/q4i2/Projects/web-perf/node_modules/aws-sdk/lib/sequential_executor.js:95:12)

This error was marked fixed on March 25th, 2015. Perhaps it has resurfaced? Or maybe I'm doing something wrong?
#46

Here is my file under test:

"use strict";

const aws = require("aws-sdk");

// Environment Configuration
const tableName = process.env.TRACE_TABLE_NAME;

const dynamo = new aws.DynamoDB.DocumentClient();

/**
 * Retrieves a trace by id, its primary key.
 *
 * @param {string} id - The requested trace's id.
 * @returns {Promise.<Object>} - A promise that is fulfilled with the requested
 *     trace's object literal. Rejects to an Error if one is encountered that
 *     prevents item retrieval.
 */
module.exports = exports = function getTrace(id) {
    const params = {
        TableName: tableName,
        Key: {
            id: id
        }
    };

    console.log(`[Retrieve] Attempting retrieval of trace from table: "${tableName}" with id: "${id}"`);

    return dynamo.get(params).promise()
        .then(data => data.Item);
};

And here is the test itself:

"use strict";

const aws = require("aws-sdk");
const chai = require("chai");
const chaiAsPromised = require("chai-as-promised");
const path = require("path");
const proxy = require("proxy-agent");
const Replay = require("replay");

Replay.mode = "record";
Replay.fixtures = path.resolve(__dirname, "..", "mocks", "aws");

// Mock Environment Configuration
process.env.TRACE_TABLE_NAME = "device-trace-service-develop-TracesTable-ODDXB1CT7ERX";
process.env.AWS_DEFAULT_REGION = "us-west-2";
aws.config.update({
    region: "us-west-2",
    httpOptions: {
        agent: proxy("http://webproxy.nordstrom.net:8181"),

        // Timeout after 5 minutes
        timeout: 300000
    }
});

const getTrace = require("./get-trace");

const expect = chai.expect;
chai.use(chaiAsPromised);

describe("getTrace(id)", () => {
    it("should do things", () => {
        return expect(getTrace("2c513185-92fc-4986-abaf-a6cd0b331fd6"))
            .to.eventually.deep.equal({
                "completedAt": "2017-05-08T19:29:54.346Z",
                "device": "google-pixel",
                "id": "2c513185-92fc-4986-abaf-a6cd0b331fd6",
                "isComplete": true,
                "isProcessing": false,
                "pageName": "test-page-name",
                "requestedAt": "2017-05-08T19:29:09.772Z",
                "s3Bucket": "device-trace-service-develop-devicetracebucket-19e08o9pmuvp7",
                "s3Key": "1494271781592-google-pixel.json",
                "s3Url": "https://device-trace-service-develop-devicetracebucket-19e08o9pmuvp7.s3-us-west-2.amazonaws.com/1494271781592-google-pixel.json",
                "startedAt": "2017-05-08T19:29:13.839Z",
                "url": "https://s3-us-west-2.amazonaws.com/device-profiling-demo/home-page-slow-profile.html"
            });
    });
});

Any help would be appreciated. Thanks!

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

No branches or pull requests

1 participant