microsoft / BotFramework-Emulator

A desktop application that allows users to locally test and debug chat bots built with the Bot Framework SDK.
https://aka.ms/botemulator
MIT License
1.81k stars 753 forks source link

Cannot connect - socket hang up #414

Closed yogiderek closed 5 years ago

yogiderek commented 6 years ago

Emulator v3.5.35

I cannot connect to the emulator using localhost:3979/api/messages. My experiences are similar to #401 except the error message in my case is "POST socket hang up". I am also behind a company firewall using a .pac file.

I have tried using 127.0.0.1:3979 which gives the same socket hang up error. Also tried https://localhost:3979/api/messages but this gives the error shown below.

Opening localhost:3979/api/messages in a browser gives me the same error as #401

<Error>
<Message>
The requested resource does not support http method 'GET'.
</Message>
</Error>

The interesting thing is that the emulator works ok on my old development PC at work. I ensured that nodejs was the latest LTS on both PCs but no joy. socket hang up error https

eanders-ms commented 6 years ago

We have an experimental fix for this in the master branch. Would you be willing to sync and build the emulator locally to see if the fix works for you? It's pretty easy to build and run it. Instructions are here: https://github.com/Microsoft/BotFramework-Emulator/wiki/How-to-Contribute#clone-and-build

I'd greatly appreciate it if you could do this, as we have no local repro!

yogiderek commented 6 years ago

Ok. Will do.

yogiderek commented 6 years ago

npm install gives the following error

18958 warn The package restify is included as both a dev and production dependency.
18959 warn optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-linux@1.3.1 (node_modules\7zip-bin-linux):
18960 warn optional SKIPPING OPTIONAL DEPENDENCY: 403 Forbidden: 7zip-bin-linux@https://registry.npmjs.org/7zip-bin-linux/-/7zip-bin-linux-1.3.1.tgz
18961 verbose stack Error: 403 Forbidden: fcopy-pre-bundled@https://registry.npmjs.org/fcopy-pre-bundled/-/fcopy-pre-bundled-0.3.4.tgz
18961 verbose stack     at fetch.then.res (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\fetch.js:42:19)
18961 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
18961 verbose stack     at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
18961 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
18961 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
18961 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
18961 verbose stack     at Async._drainQueue (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
18961 verbose stack     at Async._drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
18961 verbose stack     at Immediate.Async.drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
18961 verbose stack     at runCallback (timers.js:789:20)
18961 verbose stack     at tryOnImmediate (timers.js:751:5)
18961 verbose stack     at processImmediate [as _immediateCallback] (timers.js:722:5)
18962 verbose cwd C:\Users\derekbain\BotFramework-Emulator
18963 verbose Windows_NT 10.0.16299
18964 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
18965 verbose node v8.9.4
18966 verbose npm  v5.6.0
18967 error code E403
18968 error 403 Forbidden: fcopy-pre-bundled@https://registry.npmjs.org/fcopy-pre-bundled/-/fcopy-pre-bundled-0.3.4.tgz
eanders-ms commented 6 years ago

Probably due to your proxy configuration :). Try using http to access the registry: npm config set registry http://registry.npmjs.org/

yogiderek commented 6 years ago

These are my current settings for npm

proxy=http://127.0.0.1:3128/
https-proxy=http://127.0.0.1:3128
strict-ssl=false
registry=http://registry.npmjs.org/

I have to use cntlm to get through the firewall.

yogiderek commented 6 years ago

Overcome the npm install problem by installing yarn and running "yarn install". However npm build gives the following error

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle botframework-emulator@3.5.35~prebuild: botframework-emulator@3.5.35
6 info lifecycle botframework-emulator@3.5.35~build: botframework-emulator@3.5.35
7 verbose lifecycle botframework-emulator@3.5.35~build: unsafe-perm in lifecycle true
8 verbose lifecycle botframework-emulator@3.5.35~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\derekbain\BotFramework-Emulator\node_modules\.bin;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Users\derekbain\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin;C:\Users\derekbain\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\derekbain\AppData\Local\GitHubDesktop\bin;C:\Users\derekbain\AppData\Roaming\npm;C:\Users\derekbain\AppData\Local\Yarn\bin
9 verbose lifecycle botframework-emulator@3.5.35~build: CWD: C:\Users\derekbain\BotFramework-Emulator
10 silly lifecycle botframework-emulator@3.5.35~build: Args: [ '/d /s /c', 'gulp build' ]
11 silly lifecycle botframework-emulator@3.5.35~build: Returned: code: 1  signal: null
12 info lifecycle botframework-emulator@3.5.35~build: Failed to exec build script
13 verbose stack Error: botframework-emulator@3.5.35 build: `gulp build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid botframework-emulator@3.5.35
15 verbose cwd C:\Users\derekbain\BotFramework-Emulator
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v8.9.4
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error botframework-emulator@3.5.35 build: `gulp build`
22 error Exit status 1
23 error Failed at the botframework-emulator@3.5.35 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
eanders-ms commented 6 years ago

What do you see if you run gulp build directly?

yogiderek commented 6 years ago

First mistake - gulp not installed so i installed gulp globally.

Still failed running gulp build. The last part of the error is below. I have attached the output piped to a file.

Failed to compile TypeScript: Error: tsc command has exited with code:1

events.js:183
      throw er; // Unhandled 'error' event
      ^
Error: Failed to compile: tsc command has exited with code:1

out.txt

yogiderek commented 6 years ago

It's 11 PM in the UK just now. I will continue tomorrow. But keep the comments coming and i will continue at work in the morning. Thanks for the help so far

yogiderek commented 6 years ago

If I try to build within VS Code, I can look at the Problems view and see a list of errors e.g.

file: 'file:///c%3A/Users/derekbain/BotFramework-Emulator/%5B18%3A46%3A45%5D%20%5Btsc%5D%20%3E%20node_modules/%40types/react-dom/node_modules/%40types/react/index.d.ts'
severity: 'Error'
message: 'Subsequent property declarations must have the same type.  Property 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.'
at: '3754,13'
source: ''
code: 'TS2717'

If I click on this error I get this in a pop up window beneath the menu

Unable to open 'index.d.ts': File not found (file:///c:/Users/derekbain/BotFramework-Emulator/[18:46:45] [tsc] > node_modules/@types/react-dom/node_modules/@types/react/index.d.ts)

If I put the path into File Explorer I can navigate to the folder and the file exists.

I have googled the error TS2717 and can only find one reference to it but the solution is based on should.js which does not appear in the project.

EricDahlvang commented 6 years ago

Please try removing node_modules/@types/react-dom and running yarn upgrade @types/react-dom

yogiderek commented 6 years ago

Still fails to build. Is the last warning in the yarn upgrade output below significant

yarn upgrade v1.3.2
warning package.json: "dependencies" has dependency "restify" with range "4.3.0" that collides with a dependency in "devDependencies" of the same name with version "5.1.0"
warning botframework-emulator@3.5.35: "dependencies" has dependency "restify" with range "4.3.0" that collides with a dependency in "devDependencies" of the same name with version "5.1.0"
warning botframework-emulator@3.5.35: "dependencies" has dependency "restify" with range "4.3.0" that collides with a dependency in "devDependencies" of the same name with version "5.1.0"
warning botframework-emulator@3.5.35: "dependencies" has dependency "restify" with range "4.3.0" that collides with a dependency in "devDependencies" of the same name with version "5.1.0"
[1/4] Resolving packages...
[2/4] Fetching packages...
info 7zip-bin-linux@1.3.1: The platform "win32" is incompatible with this module.
info "7zip-bin-linux@1.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info 7zip-bin-mac@1.0.1: The platform "win32" is incompatible with this module.
info "7zip-bin-mac@1.0.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Rebuilding all packages...
success Saved lockfile.
success Saved 1 new dependency.
└─ @types/react-dom@0.14.23
warning botframework-emulator@3.5.35: "dependencies" has dependency "restify" with range "4.3.0" that collides with a dependency in "devDependencies" of the same name with version "5.1.0"
warning "@types/react-dom" is already in "devDependencies". Please remove existing entry first before adding it to "dependencies".
Done in 4.90s.
yogiderek commented 6 years ago

I have tried ncu -u followed by yarn install and then gulp build with no success, I still get the above errors. I have tried to clone the repo on a laptop and have the exact same build errors so the problem is definitely not a configuration issue with my PC.

yogiderek commented 6 years ago

I got the source to build and run on the laptop by completely removing the repo, npm and nodejs and then reinstalling everything from scratch. Note that I managed to get it to work with npm install this time and not yarn install. I then copied the full project folder over to the PC and it runs ok there. Not ideal but it is now working and the socket hangup errors have at least been resolved by using the updated source and I can now debug what is wrong with my linked server connection string and query.

I think the problem may be the corporate firewall.

Thanks for the help

eanders-ms commented 6 years ago

Thank you for your persistence. This is very encouraging news. Perhaps this is a good fix.

cwhitten commented 5 years ago

Closing due to lack of activity

manuartero commented 4 years ago

I've ended up here with exactly the same problem. Sad to see this was just discarded

tonyanziano commented 4 years ago

Hi @manutero ,

I'm sorry that you are not satisfied with the state of this issue.

It is very difficult for us to ensure that the Emulator works for every possible network configuration that our users may be behind especially when including unknowns like corporate firewalls and proxies.

We have logic in the Emulator that checks the HTTPS_PROXY and NO_PROXY environment variables before sending out any requests to the bot. HTTPS_PROXY dictates the proxy server that outgoing network traffic must travel through before reaching the destination, and NO_PROXY is a list of domains for which the proxy can be bypassed. Feel free to check #1950 or this source for more context.

I would recommend setting those before using the Emulator if you are behind some sort of proxy or corporate firewall.

NereaCabiedasMoreno commented 3 years ago

I have made a bot with Node.js locally, then in the Azure platform I have created a bot channel registration and in the messaging endpoint I have put the address of the server where I have uploaded and the bot is executed (https: // ___ : 3978 / api / messages), with this address the bot in the bot framework emulator works for me, on the other hand, in the channel registration bot I have created a channel to test the web chat but I get the following error "There was an error sending this message to your bot: HTTP status code NotFound ", I need help

tonyanziano commented 3 years ago

Hi @NereaCabiedasMoreno ,

Can you clarify a few things for me just so I understand your issue?

  1. Is your bot running locally on your machine or is it running on an exposed VM / server somewhere?
  2. You said you were able to talk to the bot from the Emulator. Was the URL you entered into the Emulator a localhost URL or some public web URL?