Provide UserName<553> message in quick - quickfix

I have created an application for FIX transactions using QuickFIX c++ API. The application is connecting to the server but the server sends "Provide UserName<553>" message. I looked for and result and found that i need to add username and password to the toAdmin method created this following code to in order to achieve that
void Application::toAdmin( FIX::Message& message, const FIX::SessionID& sessionID)
{
if (FIX::MsgType_Logon == message.getHeader().getField(FIX::FIELD::MsgType))
{
FIX44::Logon& logon_message = dynamic_cast<FIX44::Logon&>(message);
logon_message.setField(FIX::Username("my_username"));
logon_message.setField(FIX::Password("my_password"));
}
}
But then it throws and Exception. Please suggest what to do

remove this line and exception is handled
FIX44::Logon& logon_message = dynamic_cast<FIX44::Logon&>(message);
after that Put it
message.setField(FIX::Username("my_username"));
```````
message.setField(FIX::Password("my_password"));

Related

Spring Integration's `ImapIdleAdapter` doesn't mark messages as read

I have declared a mail listener with Spring Integration like this:
#Bean
public IntegrationFlow mailListener() {
return IntegrationFlows.from(
Mail.imapIdleAdapter(getUrl())
.searchTermStrategy((s, f) -> new FlagTerm(new Flags(Flags.Flag.SEEN), false))
.shouldMarkMessagesAsRead(true)
.shouldDeleteMessages(false)
.get())
.<Message>handle((payload, header) -> handle(payload)).get();
}
In my test mail account I have a few 'unread' and a few 'read' messages. Starting the application I see in the logs that the listener fetches all of the 'unread' messages over and over again without ever marking them as 'read'.
Given that I specified shouldMarkMessagesAsRead(true) I would expect the Adapter to mark a message as read after fetching it.
Am I understanding and/or doing something wrong?
Thanks to Artem Bilan's hint on activating debug output I found out that the mailbox was opened in read-only mode.
And thanks to Gary Russell's answer to another question I tried removing the .get() call on the ImapIdleChannelAdapterSpec:
#Bean
public IntegrationFlow mailListener() {
return IntegrationFlows.from(
Mail.imapIdleAdapter(getUrl())
.shouldMarkMessagesAsRead(true)
.shouldDeleteMessages(false))
.<Message>handle((payload, header) -> handle(payload)).get();
}
Now the mailbox gets opened in read-write mode and marking the messages with the SEEN flag works fine.
I also don't actually need the custom SearchTermStrategy now as Artem Bilan already suggested.
In this type of situations we recommend to set:
.javaMailProperties(p -> p.put("mail.debug", "true"))
on that Mail.imapIdleAdapter().
Probably your e-mail server really does not support that \seen flag, so the message is marked as read via some other flag.
So, with that mail debugging option you should see some interesting info in your logs.
The logic in our default DefaultSearchTermStrategy is like this around that Flags.Flag.SEEN :
if (supportedFlags.contains(Flags.Flag.SEEN)) {
NotTerm notSeen = new NotTerm(new FlagTerm(new Flags(Flags.Flag.SEEN), true));
if (searchTerm == null) {
searchTerm = notSeen;
}
else {
searchTerm = new AndTerm(searchTerm, notSeen);
}
}
See if you really need a custom strategy and why a default one is not enough for you: https://docs.spring.io/spring-integration/docs/current/reference/html/mail.html#search-term

SignalR Core - Error: Websocket closed with status code: 1006

I use SignalR in an Angular app. When I destroy component in Angular I also want to stop connection to the hub. I use the command:
this.hubConnection.stop();
But I get an error in Chrome console:
Websocket closed with status code: 1006
In Edge: ERROR Error: Uncaught (in promise): Error: Invocation canceled due to connection being closed. Error: Invocation canceled due to connection being closed.
It actually works and connection has been stopped, but I would like to know why I get the error.
This is how I start the hub:
this.hubConnection = new HubConnectionBuilder()
.withUrl("/matchHub")
.build();
this.hubConnection.on("MatchUpdate", (match: Match) => {
// some magic
})
this.hubConnection
.start()
.then(() => {
this.hubConnection.invoke("SendUpdates");
});
EDIT
I finally find the issue. Its caused by change streams from Mongo. If I remove the code from SendUpdates() method then OnDisconnected is triggered.
public class MatchHub : Hub
{
private readonly IMatchManager matchManager;
public MatchHub(IMatchManager matchManager)
{
this.matchManager = matchManager;
}
public async Task SendUpdates() {
using (var changeStream = matchManager.GetChangeStream()) {
while (changeStream.MoveNext()) {
var changeStreamDocument = changeStream.Current.FullDocument;
if (changeStreamDocument == null) {
changeStreamDocument = BsonSerializer.Deserialize<Match>(changeStream.Current.DocumentKey);
}
await Clients.Caller.SendAsync("MatchUpdate", changeStreamDocument);
}
}
}
public override async Task OnDisconnectedAsync(Exception exception)
{
await base.OnDisconnectedAsync(exception);
}
}
Method GetChangeStream from the manager.
ChangeStreamOptions options = new ChangeStreamOptions() { FullDocument = ChangeStreamFullDocumentOption.UpdateLookup };
var watch = mongoDb.Matches.Watch(options).ToEnumerable().GetEnumerator();
return watch;
But I don't know how to fix it.
This can be for many reasons but i think it is most likely this one:
I think this is because of how the server is handling the connected / disconnected events. I can't say for sure but the connection closing needs to handled correctly on the server also with code. Try overriding the built in On Connected /Disconnected methods on the server and see. My assumption only is that you're closing it but the server isn't closing properly and therefore not relaying the proper closed response.
found as a comment at : getting the reason why websockets closed with close code 1006
Where you don't need to change the connection/disconection because evrything works fine. But as an answer this one is the most likely.
It throws error because the callback doesn't get clear properly.
And it is caused by the return data from websocket.
normally it should return like
However, for some reason it might return something like
the very last response breaking into 2 pieces
And that causes the issue.
I don't think there is a way to bypass this without changing the source code.
I reported this on github repo as well at here
It turns out that I can just utilize invocation response to notify client to stop the hub. So it doesn't trigger racing issue.

Unity3D Network ReadMessage

How to check the ERROR if the client is trying to connect to a absent server?
my code!
//Server
void Start () {
NetworkServer.Listen(13044);
}
//Client
NetworkClient thisclient = new NetworkClient ();
thisclient.Connect ("127.0.0.1", 13044);
thisclient.RegisterHandler(MsgType.Error, errortest);
thisclient.RegisterHandler (MsgType.Disconnect, dctest);
void errortest(NetworkMessage netMsg){
var errorMsg = netMsg.ReadMessage<ErrorMessage>();
Debug.Log("Error:" + errorMsg.errorCode);}
void dctest(NetworkMessage netMsg){
//if I run the client while the server is not present, its goes here instead of errortest
}
You are using ReadMessage with ErrorMessage, but ErrorMessage is only valid in Error messages (OnError).
Your dctest function is triggered on disconnection, not on error.
Disconnect is a special MsgType (see https://docs.unity3d.com/ScriptReference/Networking.MsgType.html) that (if I remember) doesn't contain any data.
So to answer your question : you already have the result. Everything is in netMsg.
https://docs.unity3d.com/Manual/UNetMessages.html
The ReadMessage function is mostly used with your own NetworkMessages, when you wand to send/read custom data.

Send Message error 500 in Microsoft BotConnectorBot

I'm working with Bot Connector to reply message.
I using incomingMessage.CreateReplyMessage() it worked, but i new ConnectorClient() to reply then 500 Internal Server Error. Non-bots can't talk to non-bots
public async Task<Message> Post([FromBody]Message incomingMessage)
{
var connector = new ConnectorClient();
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("ねぇ"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("お返事ちょうだい?"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんでお返事くれないの?"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("どうして?"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("私のこと捨てるの?"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("ねぇ"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんで?"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("嘘つき"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんでこんなひどいことするの?"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんで?"));
connector.Messages.SendMessage(incomingMessage.CreateReplyMessage("なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?なんで?"));
return incomingMessage.CreateReplyMessage("今あなたの家の前にいるの");
}
I had a same problem, but https://stackoverflow.com/a/37334528/5951301 helped me to solve it:
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
{
var client = scope.Resolve<IConnectorClient>();
client.Messages.SendMessage(message);
}
Had the same problem, and in my case it was because I was using the Bot Framework Emulator to invoke my bot logic (the Post method). The only way I got the direct connection via ConnectorClient working was to do a real end-to-end test via a configured channel (like Skype).
Try this:
var connector = new ConnectorClient(new Uri("http://localhost:9000"), new ConnectorClientCredentials());
connector.Messages.SendMessage(message.CreateReplyMessage("Simple Text"));

How to intercept Error handling in SmartGWT RPCManager

I'm using SmartGWT with RestDataSource. Whenever I lose internet connection, I get an SC.warn window with:
Server returned TRANSPORT_ERROR with no error message
I have tried to intercept this message to create a more friendly message, by adding a Callback handler for RPCManager like so:
RPCManager.setHandleTransportErrorCallback(new HandleTransportErrorCallback() {
public void handleTransportError(int transactionNum, int status,
int httpResponseCode, String httpResponseText) {
System.err.println("Transaction number: "+transactionNum);
System.err.println("Status: "+status);
System.err.println("Response code: "+httpResponseCode);
System.err.println("Response text:"+httpResponseText);
SC.warn("You have no internet connection.");
}
});
However, the Error messages print, and my warn message shows, but so does the system warn message above!
Keep in mind that I'm using a RestDataSource and not directly connecting to server with RPCManager.
How can I intercept this error message?
Thanks
Try instead RPCManager.setHandleErrorCallback(..).