Parse Server, Live Query and AWS LB

Today my partner has problem to create connection for Live Query to an AWS server deploy with Elastic Beanstalk, so I have to see why he is not able to start a websocket connection.

Currently, that Parse Server is running on a EC2 instance within a VPC, with an iptable routing request from AWS LB to Nginx.

My partner has tried couple things.  Switch from AWS classic LB to Application LB, and also enable stickiness on the request.  However, he was still stuck.

After Google like everyone do, I found that  “NGINX supports WebSocket by allowing a tunnel to be set up between a client and a backend server. For NGINX to send the Upgrade request from the client to the backend server, the Upgrade and Connection headers must be set explicitly

The setting is simple, I just added those header in Nginx configuration file, and Live Query Setting is working!


For more information how to upgrade request, this is the link:

Read More

Magento redirect route in Custom Module and Observer

I was asked to redirect all routes(except admin) in Magento 1.9.2 to a custom module‘s frontend.  With Observer pattern, it is very easy to achieve it.

In Magento, when the front page layout beginning to display, an event “controller_front_send_response_before” will occur, and we will subscribe to this event to trigger our function for redirection.

To subscribe to this event, add the following xml tags in etc/config.xml in our custom module directory in the global tag.

This is what I guess the meaning of this xml tag, but I may be wrong: Magento will use singleton method, get model observer, and call customRedirect() function.  (e.g. Mage::getSingleton(‘custom_module/observer’)->customRedirect() )

Since we will need a new model “Observer”, in our custom module directory, under Model folder, create a file call “Observer.php”.

In customeRedirect() function, my code will check if this is admin path, or custommodule path.  If pattern does not match, it will redirect to custommodule route.

if you want to redirect to HTTPS route, you will need to provide the second parameter in setRedirect function like this:

setRedirect(Mage::getUrl(“customemodule/index/index”, array(‘_forced_secure’ => true);



Read More

Magento 1.9.2 Custom order amount in dashboard

A module I am building which will create a custom order, and everything is ok until I found that the Grand Total was not showing up Last 5 orders in Dashboard.


Google again, and I found that there is a property in Order Model must be set in sales_flat_order table. base_to_global_rate must set to 1.0 (I am not sure what the value meant, but 1.0 is the value that when place order normally)

Also, another problem is create custom order and I called setShippingMethod to ‘flatrate_flatrate’, in Order View it did not show up flatrate.


Google around again, and I found that I must set Shipping Description in the order, and now it works!


I have embed the Snippet from my code in Gist.

Read More