I’ve been having a bit of an issue with my AWS app going to sleep and taking a long time to handle initial requests.
I’m using .NET with Elastic Beanstalk on a T2 Micro Instance and MSSQL Server Express on RDS. My FrontEnd is a static ReactJS app that sits in S3 behind CloudFront. There’s also a load balancer across the backend.
My frontend was always instant but my initial Api calls were timing out. This ruled out S3 and CloudFront, leaving the following:
After a bit of Googling I came across something that looked fairly promising – MSSQL Server Express has a property called AutoClose set to ‘ON’ by default. AWS appears to correct this as mine was off however it’s worth checking:
-- If set to zero then auto close is offSELECT DATABASEPROPERTY('mydatabasename','IsAutoShrink')-- Check all instances at onceSELECT name,is_auto_close_on FROM sys.databases
-- Turn off if onALTERDATABASE myDB SET AUTO_CLOSE OFF
In my case the actual problem turned out to be IIS idle timeout. By default IIS automatically times out an application after 20 minutes. In order to disable this create the following ebextension:
command: "appcmd set apppool /apppool.name:DefaultAppPool /.processModel.idleTimeout:0.00:00:00"
I hit the following error when trying to execute a composed request with Fiddler:
[Fiddler] The connection to ‘abc.com’ failed. System.Security.SecurityException Failed to negotiate HTTPS connection with server.fiddler.network.https> HTTPS handshake to abc.com (for #32) failed. System.Security.Authentication.AuthenticationException A call to SSPI failed, see inner exception. < The function requested is not supported
All that was required to fix it was to add tls 1.2:
I ran into the following error after adding model validation attributes to a database with existing values:
String or binary data would be truncated.
The statement has been terminated.
The solution is pretty straightforward if you’re happy to truncate the values. Simply run the query below, swapping Title for your column name, Products for your table name and 25 for your new column length:
SET Title =LEFT(Title,25)WHERE LEN(Title)>25
You should then be able to run update-database without any issues:
Specify the ‘-Verbose’ flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201806240741543_product_validation].
Applying explicit migration: 201806240741543_product_validation.
Running Seed method.
I ran into a bit of an issue today while trying to render multiple instances of a component on a single page. Each component had a file input that was bound with an onChange event. When triggered the onChange function referenced the first component placed on the page no matter which instance was clicked.
The issue ended up being that the id of the input fields coincidentally overlapped. This meant that there were multiple instances of the field on the page with the same id value. Ensuring that each one was unique resolved the issue.
Took a fair while to narrow this one down so hopefully it’ll be able to help someone else!