mdns-js / node-mdns-js

Pure JavaScript/NodeJS mDNS discovery implementation.
Apache License 2.0
161 stars 60 forks source link

Error: trailing tokens "_tcp" in service type string "_sub._apple-mobdev2._tcp" #66

Closed liulover5 closed 7 years ago

liulover5 commented 7 years ago

LOG:

server protocol:_tcp
server serviceTokens:
server serviceTokens:_tcp
server protocol:_tcp
server serviceTokens:
server serviceTokens:_apple-mobdev2,_tcp
server protocol:_apple-mobdev2
server serviceTokens:_tcp
/usr/local/lib/node_modules/mdns-js/lib/service_type.js:123
    throw new Error('trailing tokens "' + serviceTokens.join('.') + '" in ' +
    ^

Error: trailing tokens "_tcp" in service type string "_sub._apple-mobdev2._tcp"
    at fromString (/usr/local/lib/node_modules/mdns-js/lib/service_type.js:123:11)
    at new exports.ServiceType (/usr/local/lib/node_modules/mdns-js/lib/service_type.js:31:14)
    at /usr/local/lib/node_modules/mdns-js/lib/decoder.js:40:27
    at /usr/local/lib/node_modules/mdns-js/node_modules/dns-js/lib/dnspacket.js:223:7
    at Array.forEach (native)
    at each (/usr/local/lib/node_modules/mdns-js/node_modules/dns-js/lib/dnspacket.js:221:17)
    at module.exports.decodeSection (/usr/local/lib/node_modules/mdns-js/lib/decoder.js:26:10)
    at /usr/local/lib/node_modules/mdns-js/lib/decoder.js:111:5
    at Array.forEach (native)
    at Object.module.exports.decodePackets (/usr/local/lib/node_modules/mdns-js/lib/decoder.js:99:11)
anddeMac-mini:node and$ sudo vim /usr/local/lib/node_modules/mdns-js/lib/service_type.js

code within my log in file(mdns-js/lib/service_type.js)

if you fix please update to npm org and notice me TKS!!!

105   console.log("server serviceTokens:" + serviceTokens);
|  106   protocol = serviceTokens.shift();
|  107   console.log("server protocol:" + protocol);
|  108   console.log("server serviceTokens:" + serviceTokens);
|  109   //make tcp default if not already defined
|  110   if (typeof protocol === 'undefined') {
|- 111     protocol = '_tcp';
|  112   }
|  113   checkProtocolU(protocol);
|  114   if (!isWildcard) {
|- 115     checkFormat(serviceType);
|  116   }
|  117 
|  118   if (serviceTokens.length === 1 && serviceTokens[0] === '') {
|+ 119 +---  2 lines: trailing dot-----------------------------------------------------------------------------------------------------
|  121   }
|  122   else if (serviceTokens.length > 0) {
|+ 123 +---  2 lines: throw new Error('trailing tokens "' + serviceTokens.join('.') + '" in ' +----------------------------------------
|  125   }
kmpm commented 7 years ago

Probably related to #63 but I need more input. please set the environment variable DEBUG to mdns:input and run again. DEBUG=mdns:inbound node <your code file>

This will output some messages starting with mdns:inbound and then the packet in bytes. Add those lines to this issue.

liulover5 commented 7 years ago

that's all logs when it happenned : run code ---> mibox device start ,then stop code run ,restart code( now throw error )

anddeMac-mini:node and$ DEBUG=mdns:inbound  node func/nmdns.js 
listening on localhost:8080
  mdns:inbound incoming message 000084000001000200000000095f7365727669636573075f646e732d7364045f756470056c6f63616c00000c0001c00c000c00010000000a000c045f726662045f746370c023c00c000c00010000000a0007045f736d62c03f +0ms
IP: [ '169.254.190.116' ] MAC: [ '  :  :  :  :  :  ' ] NAME: undefined FULL: undefined
  mdns:inbound incoming message 000001000001000000000000095f7365727669636573075f646e732d7364045f756470056c6f63616c00000c0001 +9ms
  mdns:inbound incoming message 000084000001000200000000095f7365727669636573075f646e732d7364045f756470056c6f63616c00000c0001c00c000c00010000000a0010085f616972706c6179045f746370c023c00c000c00010000000a0008055f72616f70c043 +123ms
IP: [ '192.168.0.105' ] MAC: [ '  :  :  :  :  :  ' ] NAME: undefined FULL: undefined
  mdns:inbound incoming message 000084000000000300000000095f7365727669636573075f646e732d7364045f756470056c6f63616c00000c000100000077000b035f7263045f746370c023c00c000c00010000007700110e5f6170706c652d6d6f6264657632c038c00c000c0001000000770007045f737562c04b +72ms
/usr/local/lib/node_modules/mdns-js/lib/service_type.js:251
    throw new Error('protocol must be either "_tcp" or "_udp" but is "' +
    ^

Error: protocol must be either "_tcp" or "_udp" but is "_apple-mobdev2"
    at checkProtocolU (/usr/local/lib/node_modules/mdns-js/lib/service_type.js:251:11)
    at fromString (/usr/local/lib/node_modules/mdns-js/lib/service_type.js:111:3)
    at new exports.ServiceType (/usr/local/lib/node_modules/mdns-js/lib/service_type.js:31:14)
    at /usr/local/lib/node_modules/mdns-js/lib/decoder.js:40:27
    at /usr/local/lib/node_modules/mdns-js/node_modules/dns-js/lib/dnspacket.js:223:7
    at Array.forEach (native)
    at each (/usr/local/lib/node_modules/mdns-js/node_modules/dns-js/lib/dnspacket.js:221:17)
    at module.exports.decodeSection (/usr/local/lib/node_modules/mdns-js/lib/decoder.js:26:10)
    at /usr/local/lib/node_modules/mdns-js/lib/decoder.js:111:5
    at Array.forEach (native)
anddeMac-mini:node and$ 
liulover5 commented 7 years ago

FIRST CODE RUN LOG ,DO NOT FOUND THROW ERROR , YOU CAN REFERRENCE:

anddeMac-mini:node and$ DEBUG=mdns:inbound  node func/nmdns.js 
listening on localhost:8080
  mdns:inbound incoming message 000084000001000200000000095f7365727669636573075f646e732d7364045f756470056c6f63616c00000c0001c00c000c00010000000a000c045f726662045f746370c023c00c000c00010000000a0007045f736d62c03f +0ms
IP: [ '169.254.190.116' ] MAC: [ '  :  :  :  :  :  ' ] NAME: undefined FULL: undefined
  mdns:inbound incoming message 000001000001000000000000095f7365727669636573075f646e732d7364045f756470056c6f63616c00000c0001 +11ms
  mdns:inbound incoming message 000084000001000200000000095f7365727669636573075f646e732d7364045f756470056c6f63616c00000c0001c00c000c00010000000a000c045f726662045f746370c023c00c000c00010000000a0007045f736d62c03f +461ms
IP: [ '192.168.0.107' ] MAC: [ '  :  :  :  :  :  ' ] NAME: undefined FULL: undefined
  mdns:inbound incoming message 000084000000000100000000106d696c696e6b31323533383837313637056c6f63616c0000018001000000780004c0a80069 +23s
  mdns:inbound incoming message 000084000000000300000000035f7263045f746370056c6f63616c00000c000100000000001815e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90c00cc026002180010000000000190000000017cb106d696c696e6b31323533383837313637c015c0260010800100000000012b1070726f747665723d31363737373530301870726f74746578743d52432056657220312e302e312e32380f706c6174666f726d5f69643d3230360a7363726e773d313932300a7363726e683d31303830267365727665725f616464726573733d6d656469612e76322e743030312e6f7474636e2e636f6d156d61633d31303a34383a62313a37353a62653a62320f736572766572706f72743d363038380e70686f746f706f72743d36303839247269643d35613331653331626634323034616530386331303234623435666463376662381761706d61633d62633a66363a38353a39373a65623a61390a6f70657261746f723d30116d6976657273696f6e3d312e332e31303205776f6c3d3116616d61633d39383a33623a31363a66643a66393a31630743503d5b36325d +5ms
IP: [ '192.168.0.105' ] MAC: [ '  :  :  :  :  :  ' ] NAME: undefined FULL: 客厅的小米盒子
  mdns:inbound incoming message 000084000000000300000000035f7263045f746370056c6f63616c00000c000100000000001815e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90c00cc026002180010000000000190000000017cb106d696c696e6b31323533383837313637c015c0260010800100000000012b1070726f747665723d31363737373530301870726f74746578743d52432056657220312e302e312e32380f706c6174666f726d5f69643d3230360a7363726e773d313932300a7363726e683d31303830267365727665725f616464726573733d6d656469612e76322e743030312e6f7474636e2e636f6d156d61633d31303a34383a62313a37353a62653a62320f736572766572706f72743d363038380e70686f746f706f72743d36303839247269643d35613331653331626634323034616530386331303234623435666463376662381761706d61633d62633a66363a38353a39373a65623a61390a6f70657261746f723d30116d6976657273696f6e3d312e332e31303205776f6c3d3116616d61633d39383a33623a31363a66643a66393a31630743503d5b36325d +885ms
  mdns:inbound incoming message 000084000000000200000000085f616972706c6179045f746370056c6f63616c00000c000100000000001815e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90c00c055f72616f70c015000c00010000000000252231303438623137356265623240e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90c043 +1s
IP: [ '192.168.0.105' ] MAC: [ '  :  :  :  :  :  ' ] NAME: undefined FULL: undefined
  mdns:inbound incoming message 000084000000000300000000035f7263045f746370056c6f63616c00000c000100000000001815e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90c00cc026002180010000000000190000000017cb106d696c696e6b31323533383837313637c015c0260010800100000000012b1070726f747665723d31363737373530301870726f74746578743d52432056657220312e302e312e32380f706c6174666f726d5f69643d3230360a7363726e773d313932300a7363726e683d31303830267365727665725f616464726573733d6d656469612e76322e743030312e6f7474636e2e636f6d156d61633d31303a34383a62313a37353a62653a62320f736572766572706f72743d363038380e70686f746f706f72743d36303839247269643d35613331653331626634323034616530386331303234623435666463376662381761706d61633d62633a66363a38353a39373a65623a61390a6f70657261746f723d30116d6976657273696f6e3d312e332e31303205776f6c3d3116616d61633d39383a33623a31363a66643a66393a31630743503d5b36325d +4ms
  mdns:inbound incoming message 000000000002000000000000055f72616f70045f746370056c6f63616c00000c0001085f616972706c6179c012000c0001 +1s
  mdns:inbound incoming message 00000000000100000001000007416e64726f6964056c6f63616c0000ff0001c00c00010001000000780004c0a80069 +48ms
  mdns:inbound incoming message 00000000000100000001000007416e64726f6964056c6f63616c0000ff0001c00c00010001000000780004c0a80069 +308ms
  mdns:inbound incoming message 00000000000300000003000007416e64726f6964056c6f63616c0000ff000115e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90085f616972706c6179045f746370c01400ff00012231303438623137356265623240e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90055f72616f70c03e00ff0001c00c00010001000000780004c0a80069c01f00210001000000780008000000001b58c00cc04900210001000000780008000000001388c00c +323ms
  mdns:inbound incoming message 00000000000200000002000015e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90085f616972706c6179045f746370056c6f63616c0000ff00012231303438623137356265623240e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90055f72616f70c02b00ff0001c00c00210001000000780010000000001b5807416e64726f6964c030c03b00210001000000780008000000001388c07c +292ms
  mdns:inbound incoming message 000084000000000200000002033130350130033136380331393207696e2d61646472046172706100000c800100000078000f07416e64726f6964056c6f63616c00c03200018001000000780004c0a80069c00c002f8001000000780006c00c00020008c032002f8001000000780005c032000140 +4ms
  mdns:inbound incoming message 00000000000200000002000015e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90085f616972706c6179045f746370056c6f63616c0000ff00012231303438623137356265623240e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90055f72616f70c02b00ff0001c00c00210001000000780010000000001b5807416e64726f6964c030c03b00210001000000780008000000001388c07c +6ms
  mdns:inbound incoming message 000000000002000000000000055f72616f70045f746370056c6f63616c00000c0001085f616972706c6179c012000c0001 +200ms
  mdns:inbound incoming message 00008400000000080000000215e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90085f616972706c6179045f746370056c6f63616c000010800100001194005e1a64657669636569643d31303a34383a62313a37353a62653a62321366656174757265733d3078313030303239666609666c6167733d307834106d6f64656c3d4170706c655456332c310e737263766572733d3135302e33330476763d31095f7365727669636573075f646e732d7364045f756470c030000c0001000011940002c022c022000c0001000011940002c00c2231303438623137356265623240e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90055f72616f70c02b001080010000119400b00674703d55445008736d3d66616c73650873763d66616c736504656b3d310865743d302c332c3506636e3d302c310463683d320573733d31360873723d34343130300870773d66616c736504766e3d3309747874766572733d310764613d747275650d66743d30783130303032394646086d643d302c312c320976733d3135302e3333097268643d342e312e330476763d3108766e3d36353533370d616d3d4170706c655456332c310673663d307834c09f000c0001000011940002c0f5c0f5000c0001000011940002c0d2c00c00218001000000780010000000001b5807416e64726f6964c030c0d200218001000000780008000000001388c1e5c00c002f8001000011940009c00c00050000800040c0d2002f8001000011940009c0d200050000800040 +106ms
IP: [ '192.168.0.105' ] MAC: [ '  :  :  :  :  :  ' ] NAME: undefined FULL: 1048b175beb2@客厅的小米盒子
  mdns:inbound incoming message 000084000000000a00000004033130350130033136380331393207696e2d61646472046172706100000c800100000078000f07416e64726f6964056c6f63616c0015e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90085f616972706c6179045f746370c03a0010800100001194005e1a64657669636569643d31303a34383a62313a37353a62653a62321366656174757265733d3078313030303239666609666c6167733d307834106d6f64656c3d4170706c655456332c310e737263766572733d3135302e33330476763d31095f7365727669636573075f646e732d7364045f756470c03a000c0001000011940002c057c057000c0001000011940002c0412231303438623137356265623240e5aea2e58e85e79a84e5b08fe7b1b3e79b92e5ad90055f72616f70c060001080010000119400b00674703d55445008736d3d66616c73650873763d66616c736504656b3d310865743d302c332c3506636e3d302c310463683d320573733d31360873723d34343130300870773d66616c736504766e3d3309747874766572733d310764613d747275650d66743d30783130303032394646086d643d302c312c320976733d3135302e3333097268643d342e312e330476763d3108766e3d36353533370d616d3d4170706c655456332c310673663d307834c0cf000c0001000011940002c125c125000c0001000011940002c102c03200018001000000780004c0a80069c04100218001000000780008000000001b58c032c10200218001000000780008000000001388c032c00c002f8001000000780006c00c00020008c041002f8001000011940009c04100050000800040c102002f8001000011940009c10200050000800040c032002f8001000000780005c032000140 +610ms
IP: [ '192.168.0.105' ] MAC: [ '  :  :  :  :  :  ' ] NAME: Android.local FULL: 1048b175beb2@客厅的小米盒子
kmpm commented 7 years ago

Same issue was discussed in https://github.com/agnat/node_mdns/issues/138. And there they concluded that it was...

Okay, I saw that the service is actually violating the specification (page 19 of http://www.ietf.org/rfc/rfc6763.txt).

I have seen a similar mobdev package in the data for #27 (not related issue though) but there the full address is 46c20544._sub._apple-mobdev2._tcp.local and in this issue it's _sub._apple-mobdev2._tcp.local.

It's missing something in the name it seems. I'll have to think about this one.