{"_id":"56cdd562f099c023009791a7","user":"55282916d9e1db2d00cd923c","__v":5,"project":"552829408962f339009a678d","version":{"_id":"552829408962f339009a6790","project":"552829408962f339009a678d","__v":26,"createdAt":"2015-04-10T19:49:20.516Z","releaseDate":"2015-04-10T19:49:20.516Z","categories":["552829418962f339009a6791","55284ed68962f339009a67e1","55286c73391a362500d9b3f4","552918f6b316811900149f59","5529b255d739240d00a3483e","553287590a578a0d008d4ff5","55329385e7d1fa0d003fc946","5550b55200420e0d00d1312f","55525fca953c9c0d00f507d7","559199695631432f002d358a","559d8d96980b801700d5ec7e","55c5e833cccdeb2d004e24b9","55d76504f662951900fc0e7d","55ea213cc62aa02f008229cd","56157b750f5ed00d00483dd8","561981fbac0924170069f4e8","561b8b1ea430930d0037ea67","563417428b86331700b488ca","56cd785bface161300dae0ec","56cdcc6e70db8a15006395f4","56cdf1b749abf10b0036a34a","56cedc8ce50c9c1b00830423","56e97ba8d825061900d1ac83","570d505228e6900e00477229","573614ca2ab52e1700c8e851","57d556a2496a3117004d70cf"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"56cdcc6e70db8a15006395f4","__v":3,"pages":["56cdcd6249abf10b0036a2e6","56cdd013f6be970b00663fc0","56cdd562f099c023009791a7"],"project":"552829408962f339009a678d","version":"552829408962f339009a6790","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-24T15:29:50.989Z","from_sync":false,"order":4,"slug":"web-sdk","title":"Web SDK"},"parentDoc":null,"updates":["577a8bf78f467e0e00868bed"],"next":{"pages":[],"description":""},"createdAt":"2016-02-24T16:08:02.881Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"Changing Endpoints are easy!\nOpen [src/index.js](https://github.com/actorapp/actor-bootstrap/blob/master/app-web/src/index.js) file and uncomment lines with endpoints to your server.\n\nFull example of `index.js` file:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import { ActorSDK, ActorSDKDelegate } from 'actor-sdk';\\n\\nconst config = {\\n  endpoints: [\\n     'wss://ws-mtproto.example.com'\\n  ]\\n};\\nconst components = {};\\nconst actions = {};\\nconst l18n = {};\\n\\nconst delegate = new ActorSDKDelegate(components, actions, l18n);\\nconst app = new ActorSDK({delegate, ...config});\\napp.startApp();\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Setting up wss-endpoint from server-side\"\n}\n[/block]\nTo use wss endpoint you need:\n\n- valid ssl certificate, e.g. free from Let's Encrypt or StartSSL;\n- set up a proxy server to redirect from port 443 to websocket endpoint, e.g. nginx, haproxy etc.\n\n\nSample nginx configuration:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"server {\\n    listen 443;\\n    server_name ws-mtproto.example.com;\\n\\n    ssl on;\\n    ssl_certificate /path/to/certificate/fullchain.pem;\\n    ssl_certificate_key /path/to/certificate/privkey.pem;\\n\\n    location = / {\\n        access_log off;\\n\\n        # Your websocket-interface\\n        proxy_pass http://127.0.0.1:9080;\\n\\n        proxy_http_version 1.1;\\n        proxy_set_header Upgrade $http_upgrade;\\n        proxy_set_header Connection \\\"upgrade\\\";\\n    }\\n\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]","excerpt":"Changing Endpoints in Web SDK","slug":"web-sdk-endpoints","type":"basic","title":"Change Endpoints"}

Change Endpoints

Changing Endpoints in Web SDK

Changing Endpoints are easy! Open [src/index.js](https://github.com/actorapp/actor-bootstrap/blob/master/app-web/src/index.js) file and uncomment lines with endpoints to your server. Full example of `index.js` file: [block:code] { "codes": [ { "code": "import { ActorSDK, ActorSDKDelegate } from 'actor-sdk';\n\nconst config = {\n endpoints: [\n 'wss://ws-mtproto.example.com'\n ]\n};\nconst components = {};\nconst actions = {};\nconst l18n = {};\n\nconst delegate = new ActorSDKDelegate(components, actions, l18n);\nconst app = new ActorSDK({delegate, ...config});\napp.startApp();", "language": "javascript", "name": null } ] } [/block] [block:api-header] { "type": "basic", "title": "Setting up wss-endpoint from server-side" } [/block] To use wss endpoint you need: - valid ssl certificate, e.g. free from Let's Encrypt or StartSSL; - set up a proxy server to redirect from port 443 to websocket endpoint, e.g. nginx, haproxy etc. Sample nginx configuration: [block:code] { "codes": [ { "code": "server {\n listen 443;\n server_name ws-mtproto.example.com;\n\n ssl on;\n ssl_certificate /path/to/certificate/fullchain.pem;\n ssl_certificate_key /path/to/certificate/privkey.pem;\n\n location = / {\n access_log off;\n\n # Your websocket-interface\n proxy_pass http://127.0.0.1:9080;\n\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection \"upgrade\";\n }\n\n}", "language": "text" } ] } [/block]