pnp / generator-teams

A Yeoman Generator for Microsoft Teams
https://pnp.github.io/generator-teams
MIT License
424 stars 111 forks source link

ngrok, error 6022, and Teams scaffoldingBug report: <short description> #335

Open elthombre opened 1 year ago

elthombre commented 1 year ago

Description

Hi, technically, this a duplicate of the following:

https://github.com/MicrosoftDocs/msteams-docs/issues/6855

It may be easiest to start at the bottom of the above incident and read backwards. The long-and-short is that the ngrok URLs that are generated from within the VS Code project do not browse as expected / as shown in the documentation samples.

Similarly, I am having trouble reaching the app from within Teams as described here:

https://github.com/MicrosoftDocs/msteams-docs/issues/4249

and this incident is also referenced in #6855.

Steps to reproduce

also from #6855:

Try the chapter 3 source:

https://github.com/Apress/pro-microsoft-teams-dev

and when I see the following:

https://docs.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/create-personal-tab?pivots=node-java-script

it doesn't appear to reference any installation or versioning of 3rd party tools such as node, ngrok, etc. How might this affect the scaffolding created by the Yeoman generator?

Are there versioning considerations?

Expected results

1) That the ngrok URLs offered up from VS Code browse as described in the documentation samples.

2) That the app can be reached as expected in Teams also as described in the documentation samples.

Actual results

also from my #6855:

In VS Code, the solution starts & runs. When the URL provided is browsed, it throws the ERR_NGROK_6022 exception.

Initially, I noted an ngrok.yml discrepancy in the utils.js: join(homedir(), ".ngrok2", "ngrok.yml") vs. "C:\Users[username]\AppData\Local/ngrok/ngrok.yml" - the latter being my ngrok location.

I then hardcoded the local path in the function and I've also updated ngrok, node, npm, etc. to latest stable versions. I continue to receive that exception.

In the dashboard, there was a 404 Not Found exception associated with GET /favicon.ico. I updated the index.html files as follows:

https://stackoverflow.com/questions/31075893/im-getting-favicon-ico-error/

https://stackoverflow.com/questions/1321878/how-to-prevent-favicon-ico-requests#

the ERR_NGROK_6022 exception persists. I have found the following:

https://stackoverflow.com/questions/71900716/im-getting-ngrok-error-6022-after-doing-everything-properly

It was my initial understanding that ngrok could not find the .yml file & associated authtoken.

and I can't reach the app as described here:

https://github.com/MicrosoftDocs/msteams-docs/issues/4249

Project you experience issues with

generator-teams

generator version

4.0.1

build tools version

1.8.0

nodejs version

v16.15.1

npm version

8.11.0 (npm) 1.22.15 (yarn)

Operating system (environment)

Windows

Additional Info

No response

stephanbisser commented 1 year ago

@elthombre you are writing the following sentence which is a bit unclear to me what you are actually doing and trying to achieve:

In VS Code, the solution starts & runs. When the URL provided is browsed, it throws the ERR_NGROK_6022 exception.

How are you executing your project? What type of solution did you scaffold using yo teams? Did you follow the prereq install guide from here?

You are referring to a lot of docs which are outside of our realm as this is the yo teams repo, so I would kindly ask you to follow the tutorial from here to see if yo teams and the prereqs for that are working accordingly on your machine:

https://pnp.github.io/generator-teams/tutorials/build-your-first-microsoft-teams-app/

elthombre commented 1 year ago

@stephanbisser in answer to your question, from here:

https://link.springer.com/book/10.1007/978-1-4842-6364-8

and here:

https://learn.microsoft.com/en-us/microsoftteams/platform/sbs-gs-javascript?tabs=vscode%2Cvsc%2Cviscode&tutorial-step=2

that said, I will start anew through the link that you provided.

elthombre commented 1 year ago

@stephanbisser , what does the following mean:

"Now you need to enter a URL of where you will host your solution. This can be any URL, but by default the generator suggests an Azure Web Sites URL."

In other words -> Azure in relation to my organization assuming my Teams work will be done under the umbrella of my organization? Azure as in a 'free Azure account'? "any URL" -> where else would it be hosted? Localhost?

stephanbisser commented 1 year ago

This is the URL which is used as the public domain name of where you host your application. So your tab will need to be deployed somewhere to an Azure Website or any other website hosting platform and you can set this URL if you know it already while scaffolding but you do not need to set it while scaffolding and testing locally. This will be necessary at the point when you will deploy your solution later on

elthombre commented 1 year ago

@stephanbisser - I do not have admin privileges for Azure within my organization. Consequently, advice that I can pass along to our admin to get this setup correctly would be helpful.

Similarly, if I do not provide a URL during scaffolding, where to look for it when I later need to change it?

stephanbisser commented 1 year ago

@elthombre you do not need to set the URL while developing your solution, therefore you can leave that blank. But later on you can set the URL in the .env file of your project -> _PUBLICHOSTNAME

elthombre commented 1 year ago

when installing 'yo', I receive a notification:

"12 vulnerabilities (5 moderate, 7 high)"

should this be a concern? no details were provided. audit fix was run.

elthombre commented 1 year ago

I am attaching the list of questions I received as there is discrepancy.

Scaffolding Questions - 10-2022

stephanbisser commented 1 year ago

@elthombre sorry but the questions you raise are somewhat not necessary directly related to the Teams generator I'm afraid like the question on vulnerabilities for yo. What do you mean by discrepancy exactly?

elthombre commented 1 year ago

@stephanbisser - I am going through the specified link provided:

https://pnp.github.io/generator-teams/tutorials/build-your-first-microsoft-teams-app/

not all of the screenshots match. Another example of what can be confusing - see the section in the above where it says to replace the code. OK. Are you are that, presently, the generator creates 3 sections in the return statements? See the below:

            <Flex.Item>
                <Header content="This is your tab" />
            </Flex.Item>
            <Flex.Item>
                <div>
                    <div>
                        <Text content={entityId} />
                    </div>

                    <div>
                        <Button onClick={() => alert("It worked!")}>A sample button</Button>
                    </div>
                </div>
            </Flex.Item>
            <Flex.Item styles={{
                padding: ".8rem 0 .8rem .5rem"
            }}>
                <Text size="smaller" content="(C) Copyright EB Control" />
            </Flex.Item>

Which to replace or all? Obviously, it's only the middle one. Not a big deal but still confusing.

Once running in the CMD, how to exit out of it or must I start a new CMD session to run the gulp ngrok-serve? I closed the first and started a new one.

What about Visual Studio Code?

Logging into your tenant is also glossed over / not mentioned. Please see the attached.

Teams Tenant

elthombre commented 1 year ago

@stephanbisser

When I attempt to browse the ngrok URL that is created from:

https://pnp.github.io/generator-teams/tutorials/build-your-first-microsoft-teams-app/

I receive ERR_NGROK_6022

elthombre commented 1 year ago

@stephanbisser , I double-checked my localhost and IIS and ngrok through localhost & got them working. I restarted my gulp serve but now receive a different error:

Failed to complete tunnel connection The connection to https://0943-2603-7080-5400-f20-5e-ddb8-1133-6140.ngrok.io/ was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:3007.

Make sure that a web service is running on localhost:3007 and that it is a valid address.

The error encountered was: dial tcp [::1]:3007: connectex: No connection could be made because the target machine actively refused it.

However, when I go to the localhost:3007, Teams displays 'Hello World'

elthombre commented 1 year ago

@stephanbisser just did a refresh and it is back to the ERR_NGROK_6022

elthombre commented 1 year ago

I am receiving:

GET /favicon.ico 404

I added a folder called "ico" and placed a favicon.ico file in it under the inetpub -> wwwroot which successfully allowed the localhost to browse to it.

Meanwhile, I have noted such a file in multiple places under the scaffolding.

wictorwilen commented 1 year ago

@elthombre - thanks for reaching out to us with a bunch of questions. In order for us to be able to help you I really would like you to keep one problem at a time and per issue. Mixing a lot of different issues in the same thread, just as this, is not productive for anyone and it will just make it harder for us to help you.

Here's a few comments

ERR_NGROK_6022 - which is the original issue of this thread. A quick lookup on that error code on the ngrok website it shows that you need to install your authtoken. What does your .env file ngrok configuration look like? <-- this should be the only thing this thread should be about

Documentation issues - please add them as separate issues, so we can track them and resolve them

vulnerabilities shown at install - please add them as a separate issue, so we can track it and comment on why this is shown

mentions about IIS - please start a separate thread about this, so we can sort that out. There's nothing with yo teams that has to do with IIS, inetpub etc.

There might be more issues mentioned here, but I can't really follow that so please create separate threads

elthombre commented 1 year ago

@wictorwilen OK, I can add threads but please do keep in mind that this thread is really about that tutorial. If there are steps missing or the documentation images do not reflect the current installations, it should be updated.

wictorwilen commented 1 year ago

Thanks @elthombre

I read the initial post again. The only tutorial I could find associated to this project (generator-teams) was this https://docs.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/create-personal-tab?pivots=node-java-script

This is a tutorial not owned by us, and you should report any feedback on that tutorial directly on that page. I notice you request that it does not specifically demonstrate how to install node.js or ngrok. It is linked to prerequisites in the tutorial where this requirement is spelled out. For ngrok and generator-teams you don't have to do anything, ngrok is being installed for you.

If that answers your original question then we could close this issue, right?

elthombre commented 1 year ago

@wictorwilen

In my first posting above, I provided a link to:

https://github.com/MicrosoftDocs/msteams-docs/issues/6855

wherein I specifically ask the below:

Looking a bit further, in the top-level folder, there is .env file with configuration settings:

NGROK configuration for development NGROK authentication token (leave empty for anonymous) NGROK_AUTH=

NGROK sub domain. ex "myapp" or (leave empty for random) NGROK_SUBDOMAIN=

NGROK region. (us, eu, au, ap - default is us) NGROK_REGION=

wictorwilen commented 1 year ago

Ok. And what is the question?

The .env file can be used if you want to customize the ngrok url using a paid subscription- not required. More details are in this tutorial: https://pnp.github.io/generator-teams/tutorials/build-a-tab-with-sso-support/#run-the-application-using-ngrok-serve

elthombre commented 1 year ago

@wictorwilen you brought up the .env file.

As for installing the ngrok authtoken, I went through this with ngrok support like a month or better ago and it was already installed:

ngrok config add-authtoken

ngrok runs fine and the URL it provides when it fires up displays. My localhost runs fine and displays as expected.

When I try to browse to the URL which is offered up through the tutorial, it fails.

And when we try to load the sample app in Teams, it fails.

wictorwilen commented 1 year ago

Ok. So you have manually installed and configured ngrok. That is a different story! How are you running the application locally?

elthombre commented 1 year ago

@wictorwilen I do not get your last post. I simply followed the instructions in the tutorial. It requires "prerequisites".

I am running the application (I assume you mean the sample 'Hello-World' application) from the command line. At least that is the case with this solution because the tutorial runs it from the command line.

In my original post with the other Microsoft sample app, we used Visual Studio Code. Both produced the same results.

wictorwilen commented 1 year ago

What exact command line are you using?

elthombre commented 1 year ago

@wictorwilen developer command line prompt for both.

With ngrok: ngrok http 80 with sample: gulp ngrok -serve

wictorwilen commented 1 year ago

That's your issue. The 'gulp ngrok-serve' automatically spins up ngrok (based on confit in .env). Since you're manually running ngrok you should use 'gulp serve' only

elthombre commented 1 year ago

@wictorwilen OK. So I hit Ctrl + C to quit out of both. I then restarted the sample app with 'gulp ngrok-serve'. I still receive the 404 error in relation to the /favicon.ico file on the command line and I still receive the ERR_NGROK_6022 error in the browser in association with the URL the app spins up.

wictorwilen commented 1 year ago
elthombre commented 1 year ago

@wictorwilen

There is an ngrok.yml file here:

C:\Users[username]\AppData\Local\ngrok

should I uninstall ngrok?

And assuming the above folder is removed or rendered uninvolved, where does the authtoken get installed?

wictorwilen commented 1 year ago

I honestly don't know - I don't think this scenario has been tested. But yes, I would remove the local ngrok and give it a shot. If you need an authtoken, please refer to the documentation I shared above.

elthombre commented 1 year ago

@wictorwilen OK, thanks - will give it a shot. And thanks for getting back to me on a Saturday ;-)

elthombre commented 1 year ago

Tried the tutorial on my personal machine where ngrok is not installed globally. Everything ran as expected but, when I tried to load the app in my Teams desktop app, I received the attached error:

Hello-World Fails

wictorwilen commented 1 year ago

@elthombre - I would suggest that you

1) Run Teams in a browser, open the Dev Toolbar in your browser and inspect the console and network trace for any issues 2) Check the console output - do you get any incoming requests and are any errors logged

elthombre commented 1 year ago

On the network output, the only issue is a 404 related to the config.html

On the console output, as soon as I hit the + symbol, there are over a dozen issues like the following appear:

2022-11-16T08:36:08.986Z value not found in enum type. value:

when I actually select the Hello-World app, I receive the following 4 errors in the console output:

Error while parsing the 'sandbox' attribute: '{{::ctrl.getSandboxAttributes()}}' is an invalid sandbox flag.

Unrecognized feature: '{{(ctrl.frame'.

Error while parsing the 'sandbox' attribute: '{{::ctrl.getSandboxAttributes()}}' is an invalid sandbox flag.

Failed to load resource: the server responded with a status of 404 (Not Found)

wictorwilen commented 1 year ago

What does the console output of the terminal look like (where you run the gulp commands)?

elthombre commented 1 year ago

I get a couple of warnings regarding asset size limits in the Terminal output in Visual Studio Code but I am not seeing any failures

but, as previously stated, if I try to browse the ngrok URL that is created, I get a ERR_NGROK_6022

wictorwilen commented 1 year ago

but, as previously stated, if I try to browse the ngrok URL that is created, I get a ERR_NGROK_6022

Then we're back on square one. There's presumably something wrong with your terminal and you have some ngrok settings somewhere or you have misconfigured the .env file.

elthombre commented 1 year ago

ngrok was not setup on this machine and I've not touched the .env file.

elthombre commented 1 year ago

This would also imply that there's "something wrong with [the] terminal" across multiple machines and multiple OS's. I get the same results on both my Win10 and Win11 machines.

elthombre commented 1 year ago

I did get a Microsoft sample working but there were some surprises related to certs:

https://github.com/MicrosoftDocs/msteams-docs/issues/7412#issuecomment-1314931414

elthombre commented 1 year ago

I should add that on my Win11 machine, the Generator samples takes much longer until it fails.

I also see a /favicon.ico 404 error in Terminal window output in VS Code.

elthombre commented 1 year ago

similar errors as Win10 machine:

Error while parsing the 'sandbox' attribute: '{{::ctrl.getSandboxAttributes()}}' is an invalid sandbox flag.

Unrecognized feature: '{{(ctrl.frame'.

Error while parsing the 'sandbox' attribute: '{{::ctrl.getSandboxAttributes()}}' is an invalid sandbox flag.

Failed to load resource: the server responded with a status of 404 (Not Found)

with the 404 coming on the config.html associated with the ngrok URL.

elthombre commented 1 year ago

Also on my Win11 machine... when creating the sample, I received:

error detecting the package manager. Falling back to npm.

It still built it fine and installed the packages but I figured it's worth mentioning.

wictorwilen commented 1 year ago
elthombre commented 1 year ago

console 11-17-2022

ngrok 6022 exception 11-17-2022

wictorwilen commented 1 year ago

Can you post the output from the terminal?

wictorwilen commented 1 year ago

@elthombre - what is that? Do you really see that in your terminal window?

elthombre commented 1 year ago

@wictorwilen - the previous post was the output from the console in the browser. I assume, then, you mean the output from within VS Code?

elthombre commented 1 year ago

gulp serve [23:30:43] Found additional Yo Teams plugin: yoteams-deploy [23:30:43] Using gulpfile C:\00-Vengar\generator-teams\Hello-World\gulpfile.js [23:30:43] Starting 'serve'... [23:30:43] Starting 'nuke'... [23:30:43] Finished 'nuke' after 46 ms [23:30:43] Starting 'manifest'... [23:30:43] Starting 'validate-manifest'... [23:30:43] Starting 'generateManifests'... [23:30:43] Finished 'generateManifests' after 34 ms [23:30:43] Starting 'validateSchemas'... [23:30:43] manifest.json is using manifest schema m365DevPreview [23:30:43] Finished 'validateSchemas' after 360 ms [23:30:43] Finished 'validate-manifest' after 396 ms [23:30:43] Starting 'zipTask'... [23:30:43] Creating package helloworld.zip [23:30:43] Finished 'zipTask' after 42 ms [23:30:43] Finished 'manifest' after 441 ms [23:30:43] Starting 'build'... [23:30:43] Starting 'webpack'... [23:30:43] Starting 'webpack:client'... [23:30:43] Starting 'webpack:server'... [23:30:53] Finished 'webpack:server' after 10 s [23:31:07] asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). This can impact web performance. Assets: client.js (637 KiB) [23:31:07] entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. Entrypoints: client (637 KiB) client.js

[23:31:07] webpack performance recommendations: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application. For more info visit https://webpack.js.org/guides/code-splitting/ [23:31:07] Finished 'webpack:client' after 24 s [23:31:07] Finished 'webpack' after 24 s [23:31:07] Starting 'styles'... [23:31:07] Finished 'styles' after 143 ms [23:31:07] Starting 'static:copy'... [23:31:07] Finished 'static:copy' after 19 ms [23:31:07] Starting 'static:inject'... [23:31:07] gulp-inject 1 file into index.html. [23:31:07] gulp-inject 1 file into privacy.html. [23:31:07] gulp-inject 1 file into tou.html. [23:31:07] gulp-inject 2 files into helloWorldTab\config.html. [23:31:07] gulp-inject 2 files into helloWorldTab\index.html. [23:31:07] gulp-inject 2 files into helloWorldTab\remove.html. [23:31:07] Finished 'static:inject' after 43 ms [23:31:07] Finished 'build' after 24 s [23:31:07] Starting 'nodemon'... [23:31:08] Finished 'nodemon' after 42 ms [23:31:08] Starting 'watch'... [23:31:08] PUBLIC_HOSTNAME: helloworld.azurewebsites.net [23:31:08] Watching .env msteams Initializing Microsoft Teams Express hosted App... +0ms msteams Adding CSP policy for /helloWorldTab/remove.html +0ms msteams Adding CSP policy for /helloWorldTab/config.html +1ms msteams Adding CSP policy for /helloWorldTab/index.html +0ms msteams Server running on 3007 +19ms

elthombre commented 1 year ago

@wictorwilen I posted the VS Code output a few days ago

wictorwilen commented 1 year ago

Thanks

  1. You're using gulp serve - which means that you have configured ngrok on your own (in a separate terminal)
  2. This also means that the manifest for your Teams app will use the PUBLIC_HOSTNAME in the .env file (helloworld.azurewebsites.net according to the output). Is this really what you want/use?