Skip to content

EventSourcePolyfill doesn't receive all data as postman  #231

Description

@hagerk720

i have this problem with EventSourcePolyfill , when i create new notification it doesn't receive any thing but after some number of notifications it receive the previous notifications but also it get truncated

`import { EventSourcePolyfill } from 'event-source-polyfill';

@Injectable({
providedIn: 'root'
})

getStream(): Observable {

 return new Observable((observer) => {
this.eventSource = new EventSourcePolyfill(this.streamUrl, {
    headers: {
      'Authorization': 'Bearer ' + this.authToken,
      'organization-id': this.securityDTO.OrganizationId,
    },        
  });

  this.eventSource.onmessage = (event) => {
    console.log(event);
    observer.next(event.data);
  };

  this.eventSource.onerror = (error) => {
    this.eventSource?.close();
    this.reconnect(observer);  
  };

  private reconnect(observer: any): void {
this.getStream().subscribe(observer);

}`

and this is how i call it
this.streamService.getStream().subscribe((data: any) => { const notification = JSON.parse(data); console.log(data); });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions