Added support for hub protocol
MODIFY
docs/en/advanced-concepts/grid.md
docs/en/advanced-concepts/grid.md
@@ -47,6 +47,7 @@ you will see your device on the grid console page:
"registerCycle": 5000,
"hubPort": <grid_port>,
"hubHost": "<Grid_host_name_or_grid_ip-address>"
+ "hubProtocol": "<Protocol_of_Grid_defaults_to_http>"
}
}
```

MODIFY
lib/grid-register.js
lib/grid-register.js
@@ -2,6 +2,10 @@ import request from 'request-promise';
import { fs } from 'appium-support';
import logger from './logger';
+const hubUri = (config) => {
+ const protocol = config.hubProtocol || 'http';
+ return `${protocol}://${config.hubHost}:${config.hubPort}`;
+};
async function registerNode (configFile, addr, port) {
let data;
@@ -26,7 +30,7 @@ async function registerToGrid (options_post, jsonObject) {
if (response === undefined || response.statusCode !== 200) {
throw new Error('Request failed');
}
- let logMessage = `Appium successfully registered with the grid on ${jsonObject.configuration.hubHost}:${jsonObject.configuration.hubPort}`;
+ let logMessage = `Appium successfully registered with the grid on ${hubUri(jsonObject.configuration)}`;
logger.debug(logMessage);
} catch (err) {
logger.error(`Request to register with grid was unsuccessful: ${err.message}`);
@@ -79,7 +83,7 @@ async function postRequest (data, addr, port) {
};
// the post options
let post_options = {
- url: `http://${jsonObject.configuration.hubHost}:${jsonObject.configuration.hubPort}/grid/register`,
+ url: `${hubUri(jsonObject.configuration)}/grid/register`,
method: 'POST',
body: data,
headers: post_headers,
@@ -116,7 +120,7 @@ async function isAlreadyRegistered (jsonObject) {
let id = jsonObject.configuration.id;
try {
let response = await request({
- uri: `http://${jsonObject.configuration.hubHost}:${jsonObject.configuration.hubPort}/grid/api/proxy?id=${id}`,
+ uri: `${hubUri(jsonObject.configuration)}/grid/api/proxy?id=${id}`,
method : 'GET',
timeout : 10000,
resolveWithFullResponse: true // return the full response, not just the body

Added support for hub protocol (#10434)