Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

How to handle ERR_CONNECTION_REFUSED in Ionic

$
0
0

@MarventusWP wrote:

Ionic: 3.19.0
Angular: 5.0.3
Node: 6.9.5

I have several Angular providers using HttpClient in my Ionic app hitting a Node.js server for data getting and storing.
I’m noticing an odd behavior whenever my node server is down or stopped (ERR_CONNECTION_REFUSED error):

When I run the app on my dev machine with ionic serve, my provider hits the error callback between 3 to 5 seconds after the request.

However, when I do the same on the actual built app (or running it with Ionic DevApp), the error callback gets hit a good 120 to 135 seconds after the request fires. Do I need to handle ERR_CONNECTION_REFUSED errors specially or is this a bug?

Below is the get method code from the service:

	getUserData(){
		this.loadingService.setLoadingState(true);
		this.mongoService.getUsers().subscribe(
			(response: any) => {
				this.loadingService.setLoadingState(false);
				this.mongoUsers = response;
				console.log("Mongo Users:", this.mongoUsers);
			},
			(err: any) => {
				this.loadingService.setLoadingState(false);
				alert('user error');
			}
		)
	}

Thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>