Git Product home page Git Product logo

ng2-stompjs's Introduction

Deprecated - @stomp/ng2-stompjs

This library is deprecated. It is not likely to work with Angular 10+. Please migrate to rx-stomp. Follow the migration guide and using rx-stomp with Angular.

Angular 6/7/8/9/10 Build Status

An Angular (Angular6+) style wrapper for @stomp/stompjs.

Version Compatibility

The current version is 8.x.x. The underlying @stomp/stompjs has been bottom rewritten bringing strict compatibility with STOMP standards. This is the first-ever STOMP JS client library that reliably supports binary payloads.

This version is recommended for Angular6 and higher.

It has been reported to work with ionic projects as well.

Getting started

https://stomp-js.github.io/ has tutorials and documentation.

Upgrading

Please follow migration guides.

Documentation

Samples

Older Angular versions

Version 4.x.x may be used with Angular 2/4/5 - use dependency like "^4.0.0". Documentation for 4.x.x can be accessed at https://stomp-js.github.io/ng2-stompjs/.

Contributors

License

Apache-2.0

ng2-stompjs's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar janwytze avatar kum-deepak avatar mpromonet avatar timhovius avatar tplk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng2-stompjs's Issues

please publish a version have javascript!

i got a issue .

Error: ./node_modules/@stomp/ng2-stompjs/src/stomp.service.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24) at Object.loader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32) @ ./src/app/app.module.ngfactory.js 45:0-65 @ ./src/app/main.ts,./node_modules/@stomp/ng2-stompjs/src/stomp.config.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24) at Object.loader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32) @ ./src/app/app.module.ngfactory.js 66:0-64 @ ./src/app/main.ts,./node_modules/@stomp/ng2-stompjs/index.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24) at Object.loader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32) @ ./src/app/app.module.js 15:0-63 @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts [DEBUG] Error: ./node_modules/@stomp/ng2-stompjs/src/stomp.service.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24) at Object.loader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32) @ ./src/app/app.module.ngfactory.js 45:0-65 @ ./src/app/main.ts,./node_modules/@stomp/ng2-stompjs/src/stomp.config.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24) at Object.loader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32) @ ./src/app/app.module.ngfactory.js 66:0-64 @ ./src/app/main.ts,./node_modules/@stomp/ng2-stompjs/index.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24) at Object.loader (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32) @ ./src/app/app.module.js 15:0-63 @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts at new BuildError (/Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28) at /Users/sjbwybls/Documents/gitrepo/ionic-ng2-stompjs/node_modules/@ionic/app-scripts/dist/preprocess.js:18:21 at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)

You can test this repo!
With bash ionic build --prod

Publish missing headers

Publish method is missing message headers array. I want to set the headers when I send message but there is not any way to do it as the overload accepts only queue name and message.

Update to Angular 5

Hi,

I can see that the angular version used is 4.0.0. Can you update to latest angular version?

Thanks

Headers not sent in production environment

I am simply trying to send an authorization header to the websocket(No SockJS, just websocket) on handshake.

It isn't working when I am building with --prod.

The token is only sent without the --prod.
Console output:
Normal
afbeelding
Production
afbeelding

The headers just aren't sent when --prod.

Why doesn't the build with --prod work?
--aot also doesn't work.

Get session ID from connection

After the connection:

CONNECT
data:[object Object]
administrator:false
possibleExtraGastRoles:
gestoreVenditaIAM:false
presentatoreIAM:false
notaioIAM:true
altroProfessionistaIAM:false
cancelliereIAM:false
giudiceIAM:false
collaboratoreIAM:false
name:100
accept-version:1.2,1.1,1.0
heart-beat:20000,0

I have this response:

CONNECTED
server:RabbitMQ/3.6.12
session:session-qxiL9CCP9KcgoQ3lMjbjHA
heart-beat:0,20000
version:1.2
user-name:grog

Is there a way to get the "session" in angular 4?

[Suggestion] Stomp service should not call try_connect in constructor

I'd suggest moving out try_connect() call from service constructor, and leaving method public. Executing any code, that isn't constructing object, inside constructor is considered a bad practice, and forces developers to implement some wierd walkarounds.

Consider situation when your websocket server implements csrf token protection(Default springboot security settings for example), and to connect you need to retrive csrf token through http to include it in stomp header.

You need to delay try_connect() until you get and set that stomp header, but StompService calls it automatically on constructor.
So there we need first walkaround, you extend StompService, and override try_connect() to call super.try_connect() when you get http response.

But! You can't just inject Http through constructor, or use setters because super constructor always have to be first statement. And so you need another walkaround. (I extended StompConfig and passed Http through it, and can't really think of any cleaner solution)

Spellcheck problem

Let's change the title from
"Angular2 and Angualr4 service for Stomp over Webscokets"
to
"Angular2 and Angular4 service for Stomp over Websockets"

Temp queues callback

Hi,

Before the question I would like to thank you for the good work with this library.

I'm doing a RPC like implementation, I'm passing the reply-to header in the sending message. I also receive a log message saying that the reply message arrived, but that it was unhandled.
Is it possible to set a callback for temporary queues?

Thank you.

Connect to stomp broker with ng2-stompjs

I have the following pure javascript code where I can connect successfully to my spring boot with stomp using websocket in the same port:

function connect() {
    var socket = new SockJS('/gs-guide-websocket');
    stompClient = Stomp.over(socket);
    stompClient.connect({}, function (frame) {
        setConnected(true);
        console.log('Connected: ' + frame);
        stompClient.subscribe('/topic/greetings', function (greeting) {
            showGreeting(JSON.parse(greeting.body).content);
        });
    });
}

The problem is that I'm trying to connect using a new Angular 4 app, and can't figure out how to switch the example above to work with ng2-stompjs.

I tried to configure it as the following:

const stompConfig: StompConfig = {
      // Which server?
      url: 'ws://127.0.0.1:8080/gs-guide-websocket',
      // Headers
      // Typical keys: login, passcode, host
      headers: {
      },
      // How often to heartbeat?
      // Interval in milliseconds, set to 0 to disable
      heartbeat_in: 0, // Typical value 0 - disabled
      heartbeat_out: 20000, // Typical value 20000 - every 20 seconds
      // Wait in milliseconds before attempting auto reconnect
      // Set to 0 to disable
      // Typical value 5000 (5 seconds)
      reconnect_delay: 5000,
      // Will log diagnostics on console
      debug: true
    };

but I get:

stomp.service.ts:271 Thu Jul 20 2017 13:20:12 GMT+0300  "Whoops! Lost connection to ws://127.0.0.1:8080/gs-guide-websocket"
stomp.service.ts:271 Thu Jul 20 2017 13:20:12 GMT+0300  "Error: Whoops! Lost connection to ws://127.0.0.1:8080/gs-guide-websocket"
stomp.service.ts:271 Thu Jul 20 2017 13:20:12 GMT+0300"STOMP: scheduling reconnection in 5000ms"

Any idea what's wrong with my configuration? Why the pure javascript code works and I'm unable to connect with my Angular 4 app using this library?

Any code?

Any code coming soon on this repo?

Using StompRService

I'm trying to use a delayed initialization of Stomp.

I followed the instructions as best as I could understand them and provided only StompRService in the app.module.ts file.

In my app.module.ts:

// Stomp Import
import {StompRService} from '@stomp/ng2-stompjs';

...

providers: [
    LoginService,
    StompRService
  ]

In my login component:

import { Router } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { NgForm } from '@angular/forms';
import { LoginService } from './../../services/login.service';
import { Observable } from 'rxjs/Observable';
import { StompRService } from "@stomp/ng2-stompjs";

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./../../../sass/pages/login.component.scss']
})
export class LoginComponent implements OnInit {
  error = '';
  config = {
    url: 'ws://localhost:8080/websocket',

    // Headers
    headers: {
      username: this.loginService.getUsername(),
      password: this.loginService.getPassword(),
      token: this.loginService.getToken()
    },

    // How often to heartbeat?
    // Interval in milliseconds, set to 0 to disable
    heartbeat_in: 0, // Typical value 0 - disabled
    heartbeat_out: 20000, // Typical value 20000 - every 20 seconds
    // Wait in milliseconds before attempting auto reconnect
    // Set to 0 to disable
    // Typical value 5000 (5 seconds)
    reconnect_delay: 5000,

    // Will log diagnostics on console
    debug: true
  };

  constructor(private loginService: LoginService, private router: Router,
  private _stompService: StompRService) { }

  /**
   * This method is used to call login service to verify username and password.
   * For more info refer to loginService component.
   * @param form this form object can be used to get values from HTML inputs.
   */
  loginUser(form: NgForm) {
    this.loginService.login(form.value.username, form.value.password)
      .subscribe(result => {
        if (result === true) {
          this.router.navigate(['home/admin']);
          this.initStomp();
        } else {
          // login failed
          this.error = 'Username or password is incorrect';
        }
      }, error => {
        this.error = error;
      });
  }

  public initStomp() {
      this._stompService.config = this.config;
      this._stompService.initAndConnect();
    }

  ngOnInit() { }

}

However, when I do this, my angular app won't let anything load. It says that there is no provider for StompService, but if I'm trying to use StompRService, why would it even check for StompService?

Is there something I'm missing?

Could you provide a more thorough example of how to set up a delayed stomp initalization using StompRService?

Memory leak after upgrading to angular 5

Hi

I have updated my project to angular 5 and I am using "@stomp/ng2-stompjs": "0.6.0"
I noticed memory leak. My scenario involves receiving data from server of 150KB each message every 2 seconds. I isolated memory leak to ng2-stompjs library. What I did was removed every other code and memory leak is present. Once I remove ng2-stompjs and reading the data from json file and refreshing it using a timer, memory leak goes away.

Thanks

After calling disconnect status stays 101

I have a stomp service where on component's ngOnDestroy I call stompService.disconnect();

I can see that connection is chrome dev tools stays with status 101. Is this correct behavior

image

Waiting for the subscriptions before sending queue data

Hi,

nice project. It is possible to wait for the subscriptions after reconnect before sending the queued data.
I think it is better to implement reaction (bi direction channels).
In your new implementation, it seems that resubscription and sending are at the same time. Or i dint see the point?

Lexanius

Compatibility issues question

Hi,

I saw this "Compatibility
There were compatibility issues reported, so this project has now switched to source distribution. In case it does not work for your setup, please raise a ticket."

Can you explain further please?

Stomp client ignores configuration URL

In our @angular/cli 1.2.1 project with @stomp/ng2-stompjs 0.4.2 the client ignores the url in StompConfig and connects to the webpack development server instead. Providing an existing SockJS connection doesn't have this issue. I am assuming this would only occur in development.
url: 'ws://localhost:4200/ws/service'
-> connects to http://localhost:4200/sockjs-node/info?t=1500962165906
url: new SockJS('/ws/service')
-> connects to http://localhost:4200/ws/service/info?t=1500962165906

Thanks for your effort

Reconnection also re-subscribe?

It seems to me that in case of lost connection, the library can reconnect but cannot re-subscribe all the topics automatically, is this true?

packaging problem

Hi,

When I'm trying to package my module using ng2-stompjs with ng-packagr, I get the following error.

BUILD ERROR
Could not resolve './src/stomp.service' from node_modules/@ stomp/ng2-stompjs/index.ts
Error: Could not resolve './src/stomp.service' from node_modules/@ stomp/ng2-stompjs/index.ts
at error (/home/christof/development/cover/components/socket-commands/node_modules/rollup/dist/rollup.js:185:14)
at then.resolvedId (/home/christof/development/cover/components/socket-commands/node_modules/rollup/dist/rollup.js:10062:8)

Any idea ?

Angular 5 - Compatibility

Getting this error while trying to compile code using Angular 5, and Angular CLI 1.5.

ERROR in ./node_modules/@stomp/ng2-stompjs/index.ts Module build failed: Error: D:\dev-tracker-app\tracker-app-admin\tracker-app-ng\node_modules\@stomp\ng2-stompjs\index.ts is not part of the compilatio n output. Please check the other error messages for details. at AngularCompilerPlugin.getCompiledFile (D:\dev-tracker-app\tracker-app-admin\tracker-app-ng\node_modules\@ngtools\webpack\src\angular_compiler_p lugin.js:629:23) at plugin.done.then (D:\dev-tracker-app\tracker-app-admin\tracker-app-ng\node_modules\@ngtools\webpack\src\loader.js:467:39) at process._tickCallback (internal/process/next_tick.js:103:7) @ ./src/app/admin/services/websocket.service.ts 8:0-62 @ ./src/app/admin/admin.module.ts @ ./src/$$_lazy_route_resource lazy @ ./node_modules/@angular/core/esm5/core.js @ ./src/main.ts @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

StompConfig Dynamic configuration !

how to custom settings the stompConfig's header , get the token when user login in , i want to transform the token to the stompConfig's header , How to implement ? thanks

Uncaught SyntaxError: Unexpected token export

I'm running angular 4.0.0. and the latest ng-stomp 0.3.5 with webpack and am getting the following unexpected token export when I load the application in the browser. Obviously export is es6 only

	export { StompService, StompState } from './src/stomp.service'; 
	export { StompConfigService } from './src/stomp-config.service';

Any help debugging this issue to get it to compile correctly?

Reconnection seems to be not working

If i restart my backend I get this output on the client:

Thu Feb 01 2018 15:02:59 GMT+0100 (CET) "Whoops! Lost connection to omissis/ws"
ng2-stompjs.es5.js:58 Thu Feb 01 2018 15:02:59 GMT+0100 (CET) "Error: Whoops! Lost connection to omissis/ws"
ng2-stompjs.es5.js:58 Thu Feb 01 2018 15:02:59 GMT+0100 (CET) "STOMP: scheduling reconnection in 5000ms"
ng2-stompjs.es5.js:58 Thu Feb 01 2018 15:03:04 GMT+0100 (CET) "STOMP: attempting to reconnect"
ng2-stompjs.es5.js:58 Thu Feb 01 2018 15:03:04 GMT+0100 (CET) "Opening Web Socket..."

But it stucks to this state: Opening Web Socket... no more info

Remove auto connection

Can try_connect not called from constructor.

There are cases that application logic need to finish first before connecting to broker.
Currently as soon as the instance of the StompService is initialized it is also connected
Need to be able to call connect whenever we want not when instance is created.

Reconnect/Reinitialize service

I have spring backend and Angular 2 frontend with websocket communication between. Part of my app have to be accessible anonymously, and other part requires authentication. To achieve this I'd have to remake websocket connection after authentication, because spring security "hands over" authentication to websocket on Upgrade request.
I can disconnect using .disconnect() method, but how can I reconnect after?

Disable console logging

I would like to be able to disable the websocket information that is logged in console because it is creating a lot of verbose output for my app and making it difficult to see other things in console. Everytime a new subscription message comes in I get an output of the payload and header details, etc. Is there a way to disable this?

stomp.startConnect() not pointing to right host

   //configuration 
     stomp.configure({
  
       **host:'127.0.0.1:8080',
       debug:true,
       queue:{'init':true}
     });

AFter doing stomp.startConnect() , chrome console shows this error:
zone.js:2744 GET http://localhost:4200/127.0.0.1:8080/info?t=1505100250266 404 (Not Found)

chrome_2017-09-11_00-29-52

0.5.0-bin

I just saw this release. Can you provide more info on what it is actually?

Thanks

StompService coupled to StompConfigService

Hi,

StompService is coupled on StompConfigService which in my opinion is not good. In a large enterprise system where several vhosts/username/password are used the following problems might occur :

  1. Creating a StompConfigService file for each StompService is redundant.
  2. Values should not be hardcoded into ts file but instead into config files where compilation is not needed every time broker/connection settings change

Web-socket connection not successful in chrome.

I am getting a weird error which appears only in Chrome (Version - 59.0.3071.115 (Official Build) (64-bit)), but works properly on Mozilla Firefox. This is the error I am getting, "Error during WebSocket handshake: 'Sec-WebSocket-Protocol' header must not appear more than once in a response". It will be really helpful to get some inputs, and also to know if anyone has faced such issues.

I am using ng2-stompjs in a Angular 4 project created with Angular-CLI.

Catching error

My StompService sends an Authorization header with a JWT token. But when the token is expired the server will return an error:
<<< ERROR message:Failed to send message to ExecutorSubscribableChannel[clientInboundChannel]; nested exception is org.springframework.security.authentication.CredentialsExpiredException\c Provided token is expired content-length:0

Of course this is expected behavior. But I am not able to catch the error and the StompService won't reconnect after this error, it only reconnects when the web socket is interrupted.

I would like to catch the error so I can refresh the token. Is this possible?

Angular 5 error

ERROR in ./node_modules/ng2-stomp-service/dist/stomp.service.ts
Module build failed: Error: /Users/Documents/trunow/trunowadmin_website_angular/node_modules/ng2-stomp-service/dist/stomp.service.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at AngularCompilerPlugin.getCompiledFile (/Users/inarenedpuganti/Documents/trunow/trunowadmin_website_angular/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:653:23)
at plugin.done.then (/Users/Documents/trunow/trunowadmin_website_angular/node_modules/@ngtools/webpack/src/loader.js:467:39)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
@ ./node_modules/ng2-stomp-service/index.js 2:20-51
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Add virtual host

Can you please add support for Virtual Host as rabbitmq support this functionality.

Stop watching connection state when onNext() is called

So I have discovered a weird bug:

I have subscribed to messages like this inside an injectible service:

this._stompMessages = this._stompService.subscribe('/user/queue/messages');
this.subscription = this._stompMessages.subscribe(this.on_next);

When the on_next method gets called I want to push something to a BehaviorSubject that is a property of this service. So inside on_next I do something like this:

this._messages.next(this._messages.getValue().concat(value));

This causes an UNSUBSCRIBE command, but why?

"Stop watching connection state (for /user/queue/messages)" ng2-stompjs.es5.js:58
"Will unsubscribe from /user/queue/messages at Stomp" ng2-stompjs.es5.js:58
">>> UNSUBSCRIBE id:sub-0

Cant do it work with ionic

When I try to use this library in ionic I get this error

Module build failed: Error: ENOENT: no such file or directory, open 'C:\workspace\PruebaIonic\node_modules@stomp\ng2-stompjs\index.js' at Error (native)

In angular 2 this work fine...

Thanks

Mock StompService in Karma tests?

Hello,

I'm trying to involve CI providers to run the tests for my Angular 4 application.
The problem is, that while testing I don't have any STOMP broker running.
So the application tries to reconnect to the websocket server periodically.

Is there any option to somehow mock the stomService so that the tests pass?

This is the code I have so far:

app.component.spec.ts

import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { WsClientComponent } from "./components/ws-client/ws-client.component";
import { StompService, StompConfig } from "@stomp/ng2-stompjs";
import { WS_STOMP_CONFIGURATION } from "./configs/ws-stomp-config";

describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent,
        WsClientComponent
      ],
      providers: [
        StompService,
        {
          provide: StompConfig,
          useValue: WS_STOMP_CONFIGURATION
        }
      ]
    }).compileComponents();
  }));
  it('should create the app', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));
  it(`should have as title 'app'`, async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app.title).toEqual('app');
  }));
});

ws-client.component.spec.ts


import { WsClientComponent } from './ws-client.component';
import { StompService, StompConfig } from "@stomp/ng2-stompjs";
import { WS_STOMP_CONFIGURATION } from "../../configs/ws-stomp-config";

describe('WsClientComponent', () => {
  let component: WsClientComponent;
  let fixture: ComponentFixture<WsClientComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ WsClientComponent ],
      providers: [
        StompService,
        {
          provide: StompConfig,
          useValue: WS_STOMP_CONFIGURATION
        }
      ]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(WsClientComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});

Thanks a lot!

StompConfigService removal.

Hi,

I just updated to 0.4.1 and saw that StompConfigService was removed. I have seen the demo and the configuration is hard coded into app.module.ts. This does not cause any problem as the service is initialized without any race conditions.

In a real life application configurations are in json files. How can I wait until loading of configs is done and then initialize the StompService(s) using angular dependency injection?

Thanks

is spring boot m7 and spring security 5.0 in withSockJS status 200 error

  @Configuration
  @EnableWebSocketMessageBroker
  public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

               @Override
               public void registerStompEndpoints(StompEndpointRegistry registry) {
                            registry.addEndpoint("/charm-
                            chat").setAllowedOrigins("http://localhost:4200").withSockJS();
               }

              @Override
              public void configureMessageBroker(MessageBrokerRegistry config) {
                           config.setApplicationDestinationPrefixes("/app");
                           config.enableSimpleBroker("/topic", "/queue");
               }
    }

 @Configuration
 public static class DefaultWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .csrf()
                .ignoringAntMatchers("/charm-chat/**")
                .and()
                .headers()
                .frameOptions().sameOrigin()
                .and()
                .httpBasic();
    }

    @Bean
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }
}

ERROR:

WebSocket connection to 'ws://localhost:8080/charm-chat' failed: Error during WebSocket handshake: Unexpected response code: 200

Package as compiled JS

Currently this library is distributed as ts files. We need to package it as compiled JS.

Can't send TextMessages

It seems there is a problem sending text messages to ActiveMQ broker.
According to this http://activemq.apache.org/stomp.html if content-length header is included it sends BytesMessage, if not - TextMessage. The content-length header is included by default. In order to exclude it it has to be defined like that
this.stompService.publish(queueName, message,
{
['content-length']:false
});

because stomjs checks if it true/false:
skipContentLength = if (@headers['content-length'] == false) then true else false

It is not possible to set content-length to false because StompHeaders is defined like this:
export declare type StompHeaders = {
[key: string]: string;
}
It must have string value.

node_modules/@stomp/ng2-stompjs/index.ts is missing from the TypeScript compilation.

I needed to perform an update of all angular modules for my project (Because of 'Version mismatching' error). Then I had to update angular-cli. After that, running ng serve yielded this error

ERROR in ./node_modules/@stomp/ng2-stompjs/index.ts
Module build failed: Error: /home/tichomir/web-technologies/angularjs/rota-second/client/node_modules/@stomp/ng2-stompjs/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at AngularCompilerPlugin.getCompiledFile (/home/tichomir/web-technologies/angularjs/rota-second/client/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:653:23)
at plugin.done.then (/home/tichomir/web-technologies/angularjs/rota-second/client/node_modules/@ngtools/webpack/src/loader.js:467:39)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
@ ./src/app/app.module.ts 23:20-49
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Error when connecting to an TLS/SSL endpoint

I am using RabbitMQ webstomp. Have successfully conigured the broker to use TLS/SSL.
When I try to connect though to it using the ng2-stompjs I get

WebSocket connection to 'wss://gw-dev.test.com:5671/ws' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET

 WebSocket connection to 'wss://gw-dev.test.com:5671/ws' failed: Error during WebSocket handshake: net::ERR_INVALID_HTTP_RESPONSE

SockJS support?

Very interested in porting my stompjs implementation over to use this lib. I am using it with SockJS like this:

        var socket = new SockJS(this.stompEndpoint);
        this.stompClient = Stomp.over(socket);
        this.stompClient.connect({}, function (frame) {}

I see from the examples that the url used is a standard web-socket. Can I use SockJS with this in any way? If so, any pointers would help me a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.