K6 unsupported protocol scheme \"wss\"

a few of my url calls in my har > js load test file are coming up with an error

WARN[0166] Request Failed error=“Get wss:/the_url : unsupported protocol scheme “wss””

any ideas on how to fix this

This seems like a websocket connection that was mistakenly converted to a HTTP request. I’ve added https://github.com/loadimpact/har-to-k6/issues/47, so we fix our converter to not emit such broken requests. In the meantime, if you want to keep it, k6 supports websocket connections through the k6/ws module, so you can manually fix it.

I’ve decided not to use the browser recorder because it is creating a lot of unnecessary http requests along with 3rd party calls I don’t want it to. I am now having trouble wrapping my head around how to create a user scenario where they go to the login page and then put in their email and password and click sign in and then it takes them to the next webpage and checks if it’s successful (200 status code). I have this thus far and know it doesn’t run but it gives you a basic understanding what I’m trying to do.

    import { sleep, group } from “k6”;

import http from “k6/http”;

export let options = {

maxRedirects: 0,

stages: [

{ duration: "30s", target: 5}, //simulate ramp-up of traffic from 1 to 5 users over 30 seconds

{ duration: "30s", target:5}, // stay at 5 users for 90 seconds

{ duration: "30s", target: 0},  //ramp down to 0 users over 5 seconds
]

};

export default function () {

group('visit page and login', function () {

// load homepage

var url = 'https://fakeWebsite.com';

var payload = JSON.stringify({

  email: 'aaa',

  password: 'bbb',

});

var params = {

  headers: {

    'Content-Type': 'application/json',
  },
};

http.post(url, payload, params);
}
check(res, {
'is status 200': (r) => r.status === 200,
});

}

I’m not seeing any issues here? Though keep in mind that you don’t need to start writing the script from scratch - you can take the script generated from the .har conversion and start from there, deleting requests to external websites, adjusting headers, etc.

And, in general, if your login page returns the credentials as a JSON object, you can save the http.post() result in a variable and access them that way - see https://k6.io/docs/javascript-api/k6-http/response

And if the website uses cookies, then that should be handled mostly automatically by k6, though you can also manually adjust them, if necessary: https://k6.io/docs/using-k6/cookies

Are you downloading the HAR-file directly from the recorder? When importing the recorded session into k6 Cloud, it should give you an option to filter out third-party requests (enabled by default, I think).

2 Likes