gcm not supporte in RMSPushNotificationsBundle - notifications

i'm trying to send message with the RMSPushNotificationsBundle with gcm Android.
I'm getting this error:
Uncaught exception 'RuntimeException' with message 'OS type rms_push_notifications.os.android.gcm not supported'
It's about to add an handler, in the class Notifications when sending a message :
$notifPush = new RMS\PushNotificationsBundle\Service\Notifications();
use RMS\PushNotificationsBundle\Message\AndroidMessage;
$message = new AndroidMessage();
$message->setMessage('oh it\s a new Week');
$message->setDeviceIdentifier('xxxxxxx');
$message->setGCM(true);
$notifPush->addHandler('android','gcm');
$notifPush->send($message);

When you're using it with symfony as a bundle the handlers are added automatically if you've configured the os in the config.yml (see docs).
If not, there's a handler class for every OS; you need to instantiate, configure and add it.
Example:
$iosHandler = new \RMS\PushNotificationsBundle\Service\OS\AppleNotification(ADD_CONFIG_PARAMS_HERE);
$notifPush->addHandler('rms_push_notifications.os.ios', $iosHandler);

Related

Error handler for MBassador message/event bus

I'm using MBassador 1.2.1 message/event bus. Works well. Except that I am getting this error message in my logs, repeated for each of my instantiated bus objects:
WARN: No error handler configured to handle exceptions during publication.
Error handlers can be added to any instance of AbstractPubSubSupport or via BusConfiguration.
Falling back to console logger.
The main project page shows this example line on a BusConfiguration object:
.addPublicationErrorHandler( new IPublicationErrorHandler{...} )
…yet neither my IDE nor I see any such method on the BusConfiguration class.
How should I go about installing an error handler for Mbassador?
Add it as another property when building the configuration bus:
IBusConfiguration config = new BusConfiguration()
.addFeature(Feature.SyncPubSub.Default())
.addFeature(Feature.AsynchronousHandlerInvocation.Default())
.addFeature(Feature.AsynchronousMessageDispatch.Default())
.setProperty(Properties.Common.Id, "Command Channel Bus")
.setProperty(Properties.Handler.PublicationError, new IPublicationErrorHandler() {
#Override
public void handleError(PublicationError error) {
}
});
I had the exact same issue as you and this solved my problem.

Why have I UnauthorizedAccessException when I use Service Bus MessagingFactory?

I have configured authorization via certificate. When I use NamespaceManager to GetSubscription works fine, but when I try execute any method from MessagingFactory I receive System.UnauthorizedAccessException.
string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
SubscriptionDescription subscriptionDescription = namespaceManager.GetSubscription("testTopic", "testSubscription"); // executed properly
var messagingFactory = MessagingFactory.CreateFromConnectionString(connectionString);
var exist = namespaceManager.TopicExists("TestTopic"); // throws exception
Stack trace:
System.UnauthorizedAccessException was unhandled
HResult=-2147024891
Message=The remote server returned an error: (401) Unauthorized. Authorization failed for specified action: Manage..TrackingId:d8648c5a-5185-41c8-b787-72332403b7d9_*******,TimeStamp:2014-07-14 08:34:22
Source=Microsoft.ServiceBus
What's the matter?
For use NamespaceManager you must be in ManageUsers in Service Bus Namespace. To add user to existing namespace you can use ps Set-SBNamespace
You must be in the ManageUsers list in Service Bus Namespace or have the Authorization rule that gives you the Manage right on the Topic that you are getting the subscriptions for.

flex 4.6 : Application crash if no internet connection

My mobile application is interact with WCF web services i build it in flash builder with Data/Services then put the url in the WSDL services
my issue is if the mobile starts with no internet connection it crashed
the error message in the console
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::rawChildren_getChildIndex()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemManager.as:2187]
at mx.managers::SystemRawChildrenList/getChildIndex()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemRawChildrenList.as:181]
at spark.components.supportClasses::StyleableStageText/getFormIndex()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableStageText.as:1956]
at spark.components.supportClasses::StyleableStageText/findTopmostForm()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableStageText.as:1933]
at spark.components.supportClasses::StyleableStageText/updateProxyImageForTopmostForm()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableStageText.as:2172]
at spark.components.supportClasses::StyleableStageText/commitProperties()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\supportClasses\StyleableStageText.as:1510]
at mx.core::UIComponent/validateProperties()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:8219]
at mx.managers::LayoutManager/validateClient()
at mx.managers::LayoutManager/validateClient()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:950]
at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:382]
at mx.managers::PopUpManager$/addPopUp()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\PopUpManager.as:193]
at spark.components::SkinnablePopUpContainer/open()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\SkinnablePopUpContainer.as:450]
at debug.ondevice.util::EnterDebugHostIPDialog/show()[/ndepot/fb_46_release_branch/ide_builder/com.adobe.flashbuilder.launching.multiplatform.contributor/utilswcs/src/debug/ondevice/util/EnterDebugHostIPDialog.mxml:47]
at debug.ondevice.util::DebuggerHostInfo$/showIPErrorDialog()[/ndepot/fb_46_release_branch/ide_builder/com.adobe.flashbuilder.launching.multiplatform.contributor/utilswcs/src/debug/ondevice/util/DebuggerHostInfo.as:129]
at mx.netmon::NetworkMonitorImpl/ioErrorHandler()[/ndepot/fb_46_release_branch/ide_builder/com.adobe.flexbuilder.monitors.network/netmonlibrary/src/mx/netmon/NetworkMonitorImpl.as:645]
i want to handle this error with message if no connection
i tried to put condition for internet connection when creation complete
protected function view1_creationCompleteHandler(event:FlexEvent):void
{
monitor = new URLMonitor(new URLRequest('http://www.adobe.com'));
monitor.addEventListener(StatusEvent.STATUS, announceStatus);
monitor.start();
}
public function announceStatus(e:StatusEvent):void {
trace("Status change. Current status: " + monitor.available);
(new AlertMsg()).open(this, false) ;
}
but it doesn't reached if no connection
Note : My target is android
Thanks in advance , for any help

Is there a global exception handler for NServiceBus?

The current advice on handling exceptions in NServiceBus is to use the built in facilities. Errored out messages go to the error message queue, and a log is written to disk.
But what if I want to send my errors to a service like AirBrake which has better functionality for grouping similar exceptions, metrics, and other good stuff? Is there a global exception handler I can tap into?
As mentioned in the original post the recommended solution is to use ServicePulse for monitoring errors. The client I currently work for is using a custom made centralized logger, and we want NServiceBus to log to this log store when messages are forwarded to the error queue.
We could have achieved this by just editing the log4net config if the exception from NServiceBus had included the original exception, currently NServiceBus just logs a generic error message with no details about what caused the failure.
NServiceBus has a class named NServiceBus.Faults.ErrorsNotifications which contains the following observables:
MessageSentToErrorQueue
MessageHasFailedAFirstLevelRetryAttempt
MessageHasBeenSentToSecondLevelRetries
You can subscribe to these observables when the endpoint starts, like in the following example which logs an error when messages are sent to the error queue:
public class GlobalErrorHandler : IWantToRunWhenBusStartsAndStops
{
private readonly ILogger _logger;
private readonly BusNotifications _busNotifications;
readonly List<IDisposable> _notificationSubscriptions = new List<IDisposable>();
public GlobalErrorHandler(ILogger logger, BusNotifications busNotifications)
{
_logger = logger;
_busNotifications = busNotifications;
}
public void Start()
{
_notificationSubscriptions.Add(_busNotifications.Errors.MessageSentToErrorQueue.Subscribe(LogWhenMessageSentToErrorQueue));
}
public void Stop()
{
foreach (var subscription in _notificationSubscriptions)
{
subscription.Dispose();
}
}
private void LogWhenMessageSentToErrorQueue(FailedMessage message)
{
var properties = new
{
MessageType = message.Headers["NServiceBus.EnclosedMessageTypes"],
MessageId = message.Headers["NServiceBus.MessageId"],
OriginatingMachine = message.Headers["NServiceBus.OriginatingMachine"],
OriginatingEndpoint = message.Headers["NServiceBus.OriginatingEndpoint"],
ExceptionType = message.Headers["NServiceBus.ExceptionInfo.ExceptionType"],
ExceptionMessage = message.Headers["NServiceBus.ExceptionInfo.Message"],
ExceptionSource = message.Headers["NServiceBus.ExceptionInfo.Source"],
TimeSent = message.Headers["NServiceBus.TimeSent"]
};
_logger.Error("Message sent to error queue. " + properties, message.Exception);
}
}
The observable is implemented by using Reactive Extensions, so you will have to install the NuGet package Rx-Core for this to work.
Could you maybe use a custom log4net configuration to do it?
http://help.airbrake.io/discussions/suggestions/157-net-plug-in-for-api-v2
There is an interface in NServiceBus called IManageMessageFailures, but I don't believe you can use it in conjucntion with the Second Level Retries so you would probably lose that if you did go for your own.
You could write the errors to SQL Server with log4net and the from there you could forward them to AirBrake using their API marking each error in the error table as sent afterwards maybe?
We switched to Serilog, it has perfect logging ans tracing support for NServiceBus. Creating a custom Serilog sink that will send your log events wherever you want is quite easy.
I would suggest that you create a custom endpoint that feeds off the error queue and uploads the data to AirBrake.
Side note: v4.0|4.1 will come with a nice Rest-Api that gives you nice management/querying capabilities for the errors. Tools like the Profiler and Ops will use this api to present the data to you in various ways.
http://particular.net/service-platform

Symfony2 : Failed to start the session because headers have already been sent

TL;DR
Getting an error on a Linux box with Nginx / PHP-FPM stating "Failed to start the session because headers have already been sent.". Error is not occurring on Apache local machine setup
So on my local machine I have the Symfony2 app running fine. No errors are popping up. But as soon as I deploy to our Linux Server I'm getting this error when I call a certain Action within a Controller class
Failed to start the session because headers have already been sent.
In the index action I have already called
$session = $this->getRequest()->getSession();
And in another action within the same controller class I'm calling it again. The error pops up when I try a
$session->set('foo', $bar);
In my Twig I'm calling the action by a form and a button with a formaction property like so
<form id='blahblah'>
.... some fields here .....
<button type='submit' formaction='{{path('2ndAction')}}'></a>
</form>
So on my local machine, running Apache everything run fine. The Linux server is using Nginx and php-fpm and it's crashing for some reason. I checked the phpInfo() and the session auto start is set to off. Not sure if this is an Nginx/php-fpm issue or not but I thought it may be pertinent information.
Here is the Controller declaration, indexAction(), and my 2ndAction()
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use CBSi\Utils\HTTPUtils\CURLUtil;
class StartController extends Controller
{
/**
* #var CurlUtil $curlUtil
*/
private $curlUtil;
/**
* #var AccessControl $accessControl
*/
private $accessControl;
/*placeholder for request object*/
private $requestHolder;
/**
* #Route("/path/for/action/one", name="start")
* #Template()
*/
public function indexAction()
{
$session = $this->getRequest()->getSession();
$this->curlUtil = $this->get('curlUtil');
$this->requestHolder= Request::createFromGlobals();
// Some logic is done here
return $this->render('ListEngagementBundle:Start:start.html.twig');
}
/**
* #Route("/path/to/second/action", name="2ndAction")
* #Template
*/
public function 2ndAction(){
$session = $this->getRequest()->getSession();
$this-> curlUtil = $this->get('curlUtil');
$this->requestHolder= Request::createFromGlobals();
//Some logic is done here to get the data for the session variable
$bar= logic output
$session->set('foo', $bar);
return $this->redirect($this->generateUrl('start'));
}
}
If you need more info that I can provide I will :)
So I figured it out. In the 2nd action where I was calling
$session->getRequest()->getSession();
I had to change that to
$session = new Session();
$session->start();
Go figure. :P
I've get the same error. But in my case I've placed some spaces in the AppKernel.php before the < ?php
tag. So if someone else get this error, checkout if you have some spaces or tabs before in first line of each .php file which get loaded before session get initialized.
This happens to me when in some of the scripts that anticipate $this->session->start();
there is a echo statement!
Hope this can help someone else debugging the issue
I was getting this error message every time I tried to update my database schema using symfony console and when I tried to install new dependencies using composer:
[RuntimeException]
Failed to start the session because headers have already been sent by "/var
/www/html/pulsar283/src/MyService/Local/Brasil.php" at line 153.
So, I went for check the file , and, on line 152 I found a " ?> " (php close tag ).
So, to I just remove the php close tag and the error never shown again !