Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket support #250

Closed
wants to merge 106 commits into from
Closed

Conversation

kenpachiii
Copy link

Fixes #207 and #228

Description of Issue Fixed
Added fixes to @pavel-ignatiev fork to add websocket support.

Changes proposed in this pull request:

  • DRY'd out code to remove similar functions.
  • Expanded DomainInfo class to include management of default values and setting values.
  • Upgraded all apigateway endpoints to version 2, except for createdomain for rest. As only version 1 will work for that.
  • Changed customDomain to take in a list of domains.
  • Uses a Map() iterator on lifecycle hooks to process each domain and allows for skipping domains that dont need changes or ones that are disabled.
  • Some minorish restructuring so the plugin will fail fast. Mostly around initializeDomainManager() function previously initializevariables() which will only return enabled domains.

… empty websockets structure as an additional parameter (via constructPlugin)
…tom domain and a corresponding Route53 record
…tom domain and a corresponding Route53 record
…he websocket domain and extended 'summary printing' test to cover the function again
@codyseibert
Copy link
Contributor

codyseibert commented Sep 23, 2019

My one suggestion would be to allow customDomain to be backwards compatible and fall back on the previous solution if an array is not provided.

Something else I'm noticing is that occasionally when I run this it seems to just get stuck. The last log that prints out is "Created API mapping for".... I'm looking into this now.

@idhard
Copy link

idhard commented Oct 15, 2019

what is blocking this pull request? would love to see this being released , thanks

@Gr8z
Copy link

Gr8z commented Oct 23, 2019

+1

@idhard
Copy link

idhard commented Oct 25, 2019

ping @captainsidd any chance you could review this pull request ? thanks

Copy link
Author

@kenpachiii kenpachiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@adam-nielsen
Copy link

adam-nielsen commented Nov 11, 2019

Are there any instructions on how to use this while we wait for it to get merged? I only just discovered this functionality is missing as I was in the process of trying to set up a custom domain for a Websocket service!

EDIT: Worked it out, git clone, npm run build, copy folder into own project's node_modules folder.

I get an error this.serverless.service.custom.customDomain.map is not a function which tells me I am running the correct code, however once I change this to an array as shown in the README, then I get nothing. No errors, no custom domains, no websocket domain.

Looking at the SLS_DEBUG logs, it looks like this is because the first domain is already done (why doesn't it print it in the summary like it used to?) and the second one failed because I had made up the name to see if the PR was working or not!

Serverless: [AWS apigatewayv2 200 0.286s 0 retries] getApiMappings({ DomainName: 'main.domain' })
Domain Manager: Path for main.domain is already current. Skipping...
Serverless: [AWS cloudformation 200 0.187s 0 retries] describeStackResource({ LogicalResourceId: 'WebsocketsApi',
  StackName: 'mystack' })
Serverless: [AWS apigatewayv2 404 0.192s 0 retries] getApiMappings({ DomainName: 'websocket.domain' })
Domain Manager: NotFoundException: Invalid domain name identifier specified
Domain Manager: Invalid domain name identifier specified

Will try again once I can get the new domain created, but it might be nice to handle this error in case someone makes a typo in their domain one day, rather than silently failing!

UPDATE: Once I put in a valid domain everything worked. sls create_domain looks good, and deploying works for both the REST endpoint and the Websocket endpoint.

I guess once the code is updated so that it's backwards compatible (accepting a non-array parameter) then it should be ready to merge? I also note that doesn't print a summary of the configured domains unless they have changed, so might be good to have that shown as well, just to confirm it's actually doing something as I get no output at all from it unless I use SLS_DEBUG. That and giving a nicer error message as above instead of failing silently!

@Gr8z
Copy link

Gr8z commented Dec 4, 2019

Its been 4 months, and still hasn't been merged...

@AlastairTaft
Copy link

We're running in prod without a custom domain 😬

@adam-nielsen
Copy link

My understanding is that this PR is unlikely to be merged until it's changed so that it is backwards compatible with existing serverless.yml files, otherwise once it's changed it'll break things for everyone else.

I had to remove the whole stack and redeploy to change a URL (a bug in CloudFront apparently) and as a result the production URL changed, so I'm glad I had already deployed the custom domain name with this PR, as it meant nothing consuming my service broke!

@jan-wilhelm
Copy link

I would love to see this merged. Really useful and necessary feature, thanks for the work!

@592da
Copy link

592da commented Feb 1, 2020

any updates please ?
really critical for us...

thanks

@592da
Copy link

592da commented Feb 2, 2020

tested it,
for some reason, it fails - probably because of one of the while loops...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
  customDomain:
    - domainName: apis.yyyy.com
      basePath: ${self:provider.stage}
      certificateName: "*.yyyy.com"
      certificateArn: arn:aws:acm:us-east-1:......
      createRoute53Record: true
      endpointType: "regional"
      securityPolicy: tls_1_2
      websocket: true

@sonarcloud
Copy link

sonarcloud bot commented Apr 11, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@aoskotsky-amplify
Copy link
Member

I'm closing this PR because I believe it's been implemented with #319. If you feel this PR is still needed then feel free to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Websockets api