{"action":"created","issue":{"url":"https://api.github.com/repos/ChaosGroup/json-ws/issues/48","repository_url":"https://api.github.com/repos/ChaosGroup/json-ws","labels_url":"https://api.github.com/repos/ChaosGroup/json-ws/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/ChaosGroup/json-ws/issues/48/comments","events_url":"https://api.github.com/repos/ChaosGroup/json-ws/issues/48/events","html_url":"https://github.com/ChaosGroup/json-ws/issues/48","id":177575875,"number":48,"title":"dev/2.0 API usage problems: unexpected server response (400)","user":{"login":"mkozjak","id":3506172,"avatar_url":"https://avatars.githubusercontent.com/u/3506172?v=3","gravatar_id":"","url":"https://api.github.com/users/mkozjak","html_url":"https://github.com/mkozjak","followers_url":"https://api.github.com/users/mkozjak/followers","following_url":"https://api.github.com/users/mkozjak/following{/other_user}","gists_url":"https://api.github.com/users/mkozjak/gists{/gist_id}","starred_url":"https://api.github.com/users/mkozjak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkozjak/subscriptions","organizations_url":"https://api.github.com/users/mkozjak/orgs","repos_url":"https://api.github.com/users/mkozjak/repos","events_url":"https://api.github.com/users/mkozjak/events{/privacy}","received_events_url":"https://api.github.com/users/mkozjak/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-17T13:28:39Z","updated_at":"2016-09-17T16:42:04Z","closed_at":"2016-09-17T16:42:04Z","body":"Using the dev/2.0 branch I have created a simple server and client code like this:\r\n\r\nServer:\r\n```js\r\n'use strict'\r\n\r\nconst http = require('http')\r\nconst jsonws = require('json-ws')\r\nconst transport = require('json-ws').transport\r\n\r\nconst api = new jsonws.service('1.0.0', 'testapi')\r\nconst srv = http.createServer()\r\nconst registry = jsonws.registry({\r\n  rootPath: '/rpc',\r\n  httpServer: srv\r\n})\r\n\r\napi.define({\r\n  name: 'clientConnected',\r\n  params: [{\r\n    name: 'uid',\r\n    type: 'string'\r\n  }]\r\n}, function() {\r\n})\r\n\r\nsrv.listen(10100, () => {\r\n  registry.addTransport(transport.WebSocket)\r\n  registry.addService(api)\r\n})\r\n```\r\n\r\nClient:\r\n```js\r\nvar ws = require(\"ws\")\r\n\r\nvar c = new ws(\"ws://localhost:10100/rpc/testapi/1.0.0\")\r\n\r\nc.on(\"open\", function() {\r\n  console.log(\"opened\")\r\n})\r\n\r\nc.on(\"error\", function(error) {\r\n  console.log(\"error,\", error)\r\n})\r\n\r\nc.on(\"closed\", function() {\r\n  console.log(\"closed\")\r\n})\r\n```\r\n\r\nFor some reason, ```pathToRegExp``` in ws-transport.js on line 63 fails on me and client gets its connection aborted with ```unexpected server response (400)``` in the end.\r\n\r\nUsing ```console.log(url, route)``` in a for loop I got: ```/rpc/testapi/1.0.0 /rpc```\r\n\r\nWhat am I doing wrong?"},"comment":{"url":"https://api.github.com/repos/ChaosGroup/json-ws/issues/comments/247787295","html_url":"https://github.com/ChaosGroup/json-ws/issues/48#issuecomment-247787295","issue_url":"https://api.github.com/repos/ChaosGroup/json-ws/issues/48","id":247787295,"user":{"login":"mkozjak","id":3506172,"avatar_url":"https://avatars.githubusercontent.com/u/3506172?v=3","gravatar_id":"","url":"https://api.github.com/users/mkozjak","html_url":"https://github.com/mkozjak","followers_url":"https://api.github.com/users/mkozjak/followers","following_url":"https://api.github.com/users/mkozjak/following{/other_user}","gists_url":"https://api.github.com/users/mkozjak/gists{/gist_id}","starred_url":"https://api.github.com/users/mkozjak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkozjak/subscriptions","organizations_url":"https://api.github.com/users/mkozjak/orgs","repos_url":"https://api.github.com/users/mkozjak/repos","events_url":"https://api.github.com/users/mkozjak/events{/privacy}","received_events_url":"https://api.github.com/users/mkozjak/received_events","type":"User","site_admin":false},"created_at":"2016-09-17T16:42:04Z","updated_at":"2016-09-17T16:42:04Z","body":"Aah, didn't see json-ws/client. Nice. Thanks for helping out!"}}
{"actor":{"display_login":"mkozjak"}}