{"action":"created","issue":{"url":"https://api.github.com/repos/stomp-js/ng2-stompjs/issues/71","repository_url":"https://api.github.com/repos/stomp-js/ng2-stompjs","labels_url":"https://api.github.com/repos/stomp-js/ng2-stompjs/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/stomp-js/ng2-stompjs/issues/71/comments","events_url":"https://api.github.com/repos/stomp-js/ng2-stompjs/issues/71/events","html_url":"https://github.com/stomp-js/ng2-stompjs/issues/71","id":325575682,"number":71,"title":"Not retrieving anydata on sockets. Only on init.","user":{"login":"Fridthjof","id":8543679,"avatar_url":"https://avatars2.githubusercontent.com/u/8543679?v=4","gravatar_id":"","url":"https://api.github.com/users/Fridthjof","html_url":"https://github.com/Fridthjof","followers_url":"https://api.github.com/users/Fridthjof/followers","following_url":"https://api.github.com/users/Fridthjof/following{/other_user}","gists_url":"https://api.github.com/users/Fridthjof/gists{/gist_id}","starred_url":"https://api.github.com/users/Fridthjof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fridthjof/subscriptions","organizations_url":"https://api.github.com/users/Fridthjof/orgs","repos_url":"https://api.github.com/users/Fridthjof/repos","events_url":"https://api.github.com/users/Fridthjof/events{/privacy}","received_events_url":"https://api.github.com/users/Fridthjof/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-05-23T07:10:42Z","updated_at":"2018-05-23T10:01:35Z","closed_at":null,"author_association":"NONE","body":"I've made this small test with at Spring Boot server and Angular 4 over Sockets. \r\n\r\nI have a small graph that is showing data, and should show it realtime. \r\n\r\nAt the moment i'm only getting the last data created serverData by this:\r\n```\r\n    @SubscribeMapping(\"/data\")\r\n    public List initDataConnection() {\r\n        makeRandomData(1);\r\n        System.out.println(\"Subscription on data\");\r\n        return liveDataTest;\r\n    }\r\n```\r\n\r\nCurrent my Angular looks like this\r\n\r\n```\r\n\r\nimport {Component, OnDestroy, OnInit} from '@angular/core';\r\nimport {StompService} from '@stomp/ng2-stompjs';\r\nimport {Subscription} from 'rxjs/Subscription';\r\nimport {Observable} from 'rxjs/Observable';\r\nimport {Message} from '@stomp/stompjs';\r\n\r\nimport * as Stomp from 'stompjs';\r\nimport * as SockJS from 'sockjs-client';\r\nimport * as $ from 'jquery';\r\n\r\n@Component({\r\n    selector: 'app-root',\r\n    templateUrl: './app.component.html',\r\n    styleUrls: ['./app.component.css']\r\n})\r\nexport class AppComponent implements OnInit, OnDestroy {\r\n//     private serverUrl = 'http://192.168.3.129:8080/socket';\r\n    public title = 'Websocket Test';\r\n//     private stompClient;\r\n//     private stompClientLiveData;\r\n//\r\n//     constructor() {\r\n//         this.initializeWebSocketConnection();\r\n//     }\r\n//\r\n//     ngOnInit() {\r\n//         this.initializeWebSocketConnection();\r\n//     }\r\n//\r\n//     initializeWebSocketConnection() {\r\n//         const ws = new SockJS(this.serverUrl);\r\n//\r\n//         this.stompClient = Stomp.over(ws);\r\n//         const that = this;\r\n//         this.stompClient.connect({}, function (frame) {\r\n//             that.stompClient.subscribe('/data', (message) => {\r\n//                 if (message.body) {\r\n//                     $('.chat').append('<div class=\\'message\\'>' + message.body + '</div>');\r\n//                 }\r\n//             });\r\n//         });\r\n//     }\r\n//\r\n//     sendMessage(message) {\r\n//         this.stompClient.send('/batchServer/responseData', {}, message);\r\n//         $('#input').val('');\r\n//     }\r\n// }\r\n\r\n    // Stream of messages\r\n    private subscription: Subscription;\r\n    public messages: Observable<Message>;\r\n\r\n    dataIsReady: Boolean = false;\r\n\r\n    public subscribed: boolean;\r\n\r\n    public history: Array<any> = [];\r\n\r\n    constructor(private _stompService: StompService) {\r\n    }\r\n\r\n    ngOnInit() {\r\n        this.subscribed = false;\r\n        this.subscribe();\r\n    }\r\n\r\n    public subscribe() {\r\n        if (this.subscribed) {\r\n            return;\r\n        }\r\n\r\n        // Stream of messages\r\n        this.messages = this._stompService.subscribe('/batchServer/data');\r\n\r\n        // Subscribe a function to be run on_next messages\r\n        this.subscription = this.messages.subscribe(this.onNext, error2 => console.log(error2));\r\n        this.subscribed = true;\r\n    }\r\n\r\n    public unsubscribe() {\r\n        if (!this.subscribed) {\r\n            return;\r\n        }\r\n\r\n        // This will internally unsubsribe from Stomp Broker\r\n        this.subscription.unsubscribe();\r\n        this.subscription = null;\r\n        this.messages = null;\r\n\r\n        this.subscribed = false;\r\n    }\r\n\r\n    ngOnDestroy() {\r\n        this.unsubscribe();\r\n    }\r\n\r\n    public onNext = (message: Message) => {\r\n        console.log(message);\r\n        // Store message in a history Array\r\n        this.history.push(message.body);\r\n\r\n        console.log(JSON.parse(message.body));\r\n        // this.lineChartData = ;\r\n        this.loopData(JSON.parse(message.body));\r\n    };\r\n\r\n    public makeData() {\r\n        this._stompService.publish('/batchServer/responseData', 'hello');\r\n    }\r\n}\r\n\r\n```\r\n\r\nWhen i click a button and makeData() is called, it sends a msg 'hello' which the server respons on by a \r\n\r\n`\r\n        this.template.convertAndSend(\"/data\", 'hello');\r\n`\r\n\r\nMy webproject is not retrieving any data though. \r\nIf i'm using another stomp work (outcommented code) it works as it should\r\n\r\n\r\n\r\nMy module: \r\n\r\n```\r\nexport function receiverProvider() {\r\n    return new SockJS('http://192.168.3.129:8080/socket');\r\n}\r\n\r\nconst stompConfig: StompConfig = {\r\n    // Which server?\r\n    url: receiverProvider,\r\n\r\n    // Headers\r\n    // Typical keys: login, passcode, host\r\n    headers: {\r\n    //     login: 'guest',\r\n    //     passcode: 'guest'\r\n    },\r\n\r\n    // How often to heartbeat?\r\n    // Interval in milliseconds, set to 0 to disable\r\n    heartbeat_in: 0, // Typical value 0 - disabled\r\n    heartbeat_out: 20000, // Typical value 20000 - every 20 seconds\r\n    // Wait in milliseconds before attempting auto reconnect\r\n    // Set to 0 to disable\r\n    // Typical value 5000 (5 seconds)\r\n    reconnect_delay: 10000,\r\n\r\n    // Will log diagnostics on console\r\n    debug: true\r\n};\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/stomp-js/ng2-stompjs/issues/comments/391292617","html_url":"https://github.com/stomp-js/ng2-stompjs/issues/71#issuecomment-391292617","issue_url":"https://api.github.com/repos/stomp-js/ng2-stompjs/issues/71","id":391292617,"user":{"login":"kum-deepak","id":3807337,"avatar_url":"https://avatars0.githubusercontent.com/u/3807337?v=4","gravatar_id":"","url":"https://api.github.com/users/kum-deepak","html_url":"https://github.com/kum-deepak","followers_url":"https://api.github.com/users/kum-deepak/followers","following_url":"https://api.github.com/users/kum-deepak/following{/other_user}","gists_url":"https://api.github.com/users/kum-deepak/gists{/gist_id}","starred_url":"https://api.github.com/users/kum-deepak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kum-deepak/subscriptions","organizations_url":"https://api.github.com/users/kum-deepak/orgs","repos_url":"https://api.github.com/users/kum-deepak/repos","events_url":"https://api.github.com/users/kum-deepak/events{/privacy}","received_events_url":"https://api.github.com/users/kum-deepak/received_events","type":"User","site_admin":false},"created_at":"2018-05-23T10:01:35Z","updated_at":"2018-05-23T10:01:35Z","author_association":"CONTRIBUTOR","body":"I will install IntelliJ community and try"}}
{"actor":{"display_login":"kum-deepak"}}