I created a application in spring boot that gets data from a certain website which is working completely fine on local system but once I deploy it on ec2 instance, it gets stuck on the fetching part without any error message.
Output on local system
2024/01/08 17:17:06,320 [INFO] [http-nio-8443-exec-1] getDummyData(XyzServiceImpl.java:28) - Started getting Data
2024/01/08 17:17:06,322 [INFO] [http-nio-8443-exec-1] fetchData(BaseServiceImpl.java:50) - [User-Agent:"Mozilla/5.0", Accept-Language:"*", Accept:"*"]
2024/01/08 17:17:06,322 [INFO] [http-nio-8443-exec-1] fetchData(BaseServiceImpl.java:53) - Fetching data from url - https://www.nseindia.com/api/xyz
2024/01/08 17:17:06,656 [DEBUG] [http-nio-8443-exec-1] debug(CompositeLog.java:127) - HTTP GET https://www.nseindia.com/api/xyz
2024/01/08 17:17:06,671 [DEBUG] [http-nio-8443-exec-1] debug(CompositeLog.java:127) - Accept=[text/plain, application/json, application/*+json, */*]
2024/01/08 17:17:07,000 [DEBUG] [http-nio-8443-exec-1] debug(CompositeLog.java:127) - Response 200 OK
2024/01/08 17:17:07,003 [DEBUG] [http-nio-8443-exec-1] debug(CompositeLog.java:127) - Reading to [java.lang.String] as "application/json;charset=utf-8"
2024/01/08 17:17:07,009 [INFO] [http-nio-8443-exec-1] getDummyData(XyzServiceImpl.java:30) - Fetched Data
2024/01/08 17:17:07,010 [INFO] [http-nio-8443-exec-1] getDummyData(XyzServiceImpl.java:32) - Status Code is :200 OK
2024/01/08 17:17:07,011 [INFO] [http-nio-8443-exec-1] getDummyData(XyzServiceImpl.java:34) - Successfully Fetched Data
2024/01/08 17:17:07,047 [DEBUG] [http-nio-8443-exec-1] writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:275) - Using 'application/json;q=0.8', given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8, application/signed-exchange;v=b3;q=0.7] and supported [application/json, application/*+json]
2024/01/08 17:17:07,079 [TRACE] [http-nio-8443-exec-1] prepareResponse(WebContentGenerator.java:405) - Applying default cacheSeconds=-1
2024/01/08 17:17:07,080 [TRACE] [http-nio-8443-exec-1] processDispatchResult(DispatcherServlet.java:1166) - No view rendering, null ModelAndView returned.
2024/01/08 17:17:07,080 [DEBUG] [http-nio-8443-exec-1] logResult(FrameworkServlet.java:1135) - Completed 200 OK, headers={masked}
2024/01/08 17:17:07,083 [DEBUG] [http-nio-8443-exec-1] log(DirectJDKLog.java:173) - Before fill(): parsingHeader: [true], parsingRequestLine: [true], parsingRequestLinePhase: [0], parsingRequestLineStart: [0], byteBuffer.position(): [0], byteBuffer.limit(): [0], end: [696]
2024/01/08 17:17:07,084 [DEBUG] [http-nio-8443-exec-1] log(DirectJDKLog.java:173) - Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@6a70d5b9:org.apache.tomcat.util.net.NioChannel@3773a49:java.nio.channels.SocketChannel[connected local=/[0:0:0:0:0:0:0:1]:8443 remote=/[0:0:0:0:0:0:0:1]:51225]], Read from buffer: [0]
2024/01/08 17:17:07,085 [DEBUG] [http-nio-8443-exec-1] log(DirectJDKLog.java:173) - Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@6a70d5b9:org.apache.tomcat.util.net.NioChannel@3773a49:java.nio.channels.SocketChannel[connected local=/[0:0:0:0:0:0:0:1]:8443 remote=/[0:0:0:0:0:0:0:1]:51225]], Read direct from socket: [0]
2024/01/08 17:17:07,085 [DEBUG] [http-nio-8443-exec-1] log(DirectJDKLog.java:173) - Received []
2024/01/08 17:17:07,086 [DEBUG] [http-nio-8443-exec-1] log(DirectJDKLog.java:173) - Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@6a70d5b9:org.apache.tomcat.util.net.NioChannel@3773a49:java.nio.channels.SocketChannel[connected local=/[0:0:0:0:0:0:0:1]:8443 remote=/[0:0:0:0:0:0:0:1]:51225]], Status in: [OPEN_READ], State out: [OPEN]
2024/01/08 17:17:07,087 [DEBUG] [http-nio-8443-exec-1] log(DirectJDKLog.java:173) - Registered read interest for [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@6a70d5b9:org.apache.tomcat.util.net.NioChannel@3773a49:java.nio.channels.SocketChannel[connected local=/[0:0:0:0:0:0:0:1]:8443 remote=/[0:0:0:0:0:0:0:1]:51225]]
2024/01/08 17:17:07,088 [DEBUG] [http-nio-8443-Poller] log(DirectJDKLog.java:173) - timeout completed: keys processed=2; now=1704714427088; nextExpiration=1704714426711; keyCount=0; hasEvents=true; eval=false
2024/01/08 17:17:08,089 [DEBUG] [http-nio-8443-Poller] log(DirectJDKLog.java:173) - timeout completed: keys processed=2; now=1704714428089; nextExpiration=1704714428088; keyCount=0; hasEvents=false; eval=false
Ouput on ec2 instance
2024/01/08 11:46:05,269 [INFO] [http-nio-8443-exec-1] getDummyData(XyzServiceImpl.java:28) - Started getting Data
2024/01/08 11:46:05,271 [INFO] [http-nio-8443-exec-1] fetchData(BaseServiceImpl.java:50) - [User-Agent:"Mozilla/5.0", Accept-Language:"*", Accept:"*"]
2024/01/08 11:46:05,271 [INFO] [http-nio-8443-exec-1] fetchData(BaseServiceImpl.java:53) - Fetching data from url - https://www.nseindia.com/api/xyz
2024/01/08 11:46:05,535 [DEBUG] [http-nio-8443-exec-1] debug(CompositeLog.java:127) - HTTP GET https://www.nseindia.com/api/xyz
2024/01/08 11:46:05,555 [DEBUG] [http-nio-8443-exec-1] debug(CompositeLog.java:127) - Accept=[text/plain, application/json, application/*+json, */*]
2024/01/08 11:46:06,077 [DEBUG] [http-nio-8443-Poller] log(DirectJDKLog.java:173) - timeout completed: keys processed=2; now=1704714366077; nextExpiration=1704714365327; keyCount=0; hasEvents=false; eval=false
2024/01/08 11:46:07,079 [DEBUG] [http-nio-8443-Poller] log(DirectJDKLog.java:173) - timeout completed: keys processed=2; now=1704714367079; nextExpiration=1704714367077; keyCount=0; hasEvents=false; eval=false
Internet is enabled on ec2 instance.