Hello, I want to connect all my bots via proxy servers to give them separate IP's to connect them to steam for trading and getting users inventory. Yesterday I tried around many hours and could not find any workings solution. I end up with this code: (free proxy's to test only)
const steam = require('steam-client');
const request = require('request');
require('request-debug')(request);
const SteamUser = require('steam-user');
const SteamCommunity = require('steamcommunity');
const SteamTotp = require('steam-totp');
const TradeOfferManager = require('steam-tradeoffer-manager');
let proxyUrl = 'https://119.28.152.208:80';
let proxifiedRequest = request.defaults({'proxy': proxyUrl});
let community = new SteamCommunity({request: proxifiedRequest});
//
// let community = new SteamCommunity();
let steamclient = new steam.CMClient();
steamclient.setHttpProxy('https://119.28.152.208:80');
let client = new SteamUser(steamclient);
let manager = new TradeOfferManager({
"community": community,
"steam": client, // Polling every 30 seconds is fine since we get notifications from Steam
"domain": "localhost", // Our domain is example.com
"language": "en" // We want English item descriptions
});
steamclient.on('error', (...data) => console.log('client-error', ...data));
steamclient.on('debug', (...data) => console.log('client-debug', ...data));
// user.on('debug', (...data) => console.log('user-debug', ...data));
// user.on('error', (...data) => console.log('user-error', ...data));
// Steam logon options
let logOnOptions = {
"accountName": config.steamAccountName,
"password": config.steamAccountPassword,
"twoFactorCode": SteamTotp.generateAuthCode(config.sharedSecret)
};
client.logOn(logOnOptions);
let botOnline = false;
client.on('loggedOn', function() {
botOnline = true;
console.log("Logged into Steam");
});
setTimeout(function () {
if (!botOnline) {
console.log("BOT TIMEOUT - RESTART");
process.exit();
}
}, 90 * 1000);
client.on('webSession', function(sessionID, cookies) {
manager.setCookies(cookies, function(err) {
if (err) {
console.log("Fatal error since we couldn't get our API key");
console.log(err);
setTimeout(() => {
process.exit(1);
}, 60000);
return;
}
console.log("Got API key: " + manager.apiKey);
[........]
but if I run this script, I instantly get an error back:
error: uncaughtException: Protocol "https:" not supported. Expected "http:"
Error: Protocol "https:" not supported. Expected "http:"
at new ClientRequest (_http_client.js:55:11)
at Object.exports.request (http.js:31:10)
at TCPConnection.connect (C:\xampp\htdocs\...\node_modules\steam-client\lib\tcp_connection.js:56:34)
at _getServer (C:\xampp\htdocs\...\node_modules\steam-client\lib\cm_client.js:119:20)
at CMClient._getServer (C:\xampp\htdocs\...\node_modules\steam-client\lib\cm_client.js:442:3)
at CMClient.connect (C:\xampp\htdocs\...\node_modules\steam-client\lib\cm_client.js:97:7)
at gotCMList (C:\xampp\htdocs\...\node_modules\steam-user\components\logon.js:171:17)
at readFileCallback (C:\xampp\htdocs\...\node_modules\steam-user\components\logon.js:117:4)
at C:\xampp\htdocs\...\node_modules\file-manager\node_modules\async\lib\async.js:52:16
the code above uses a https proxy to connect. If I use a http proxy, my console logs looks like
Starting services...
client-debug connecting to 155.133.230.34:27019
client-debug proxy timed out
client-debug socket closed
client-debug connecting to 162.254.193.7:27019
or like
client-error { Error: HTTP CONNECT 400 Bad Request
at ClientRequest.<anonymous> (C:\xampp\htdocs\...\node_modules\steam-client\lib\tcp_connection.js:70:14)
at emitThree (events.js:116:13)
at ClientRequest.emit (events.js:194:7)
at Socket.socketOnData (_http_client.js:395:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:548:20) eresult: 35 }
Does anyone have a working example to connect bots via proxy server? Whats wrong with my code and does it have something to do with steam's change to https in the past? (oAuth login for example which returns https now) Thanks <3