'Angular (failed)net::ERR_CONNECTION_TIMED_OUT
I have one weird problem. I have one angular web application in x server with https with trusted certificate. And I have one api in another y server which doesn't have trusted certificate. y server is only internal . It means only x server can reach y. I publised angular app and trying to send request to api but giving me
(failed)net::ERR_CONNECTION_TIMED_OUT
error in network. So I can't figure out what the problem is.
I tried to understand if problem is api related and tried below examples
- I created one api in x server and send request to y server with this api and it works
- I created simple html file in server and inside it tried to send request to api in y server and it works
so only Angular app doesn't send this request.
Below is my http service
import { Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root',
})
export class HttpService {
constructor(private http: HttpClient) {}
Get(url: string): Observable<any> {
return this.http.get(environment.apiUrl+ url).pipe();
}
Post(url: string, object: any): Observable<any> {
return this.http.post(environment.apiUrl+url, object).pipe();
}
Put(url: string, object: any): Observable<any> {
return this.http.put(environment.apiUrl+url, object).pipe();
}
Delete(url: string, object: any): Observable<any> {
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
}),
body: object
}
return this.http.delete(environment.apiUrl+url, options).pipe();
}
}
and I send request using this service
this._http.Post('Report/BatchCounts', this.filter).subscribe(
(result) => {
if (result.success) {
this.batchData = result.data;
}
this._loader.stop();
},
(error) => {
this._loader.stop();
}
);
what can be the problem ? What can be my problem?
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
