AWS Lambda error: HTTP 502 ‘Execution failed due to configuration error: Malformed Lambda proxy response’

Calling an AWS Lambda via API Gateway with the Lambda Proxy Integration option, you might see an HTTP 502 response and this message:

Execution failed due to configuration error: Malformed Lambda proxy response"

Wed May 30 05:00:41 UTC 2018 : Execution failed due to configuration error: Malformed Lambda proxy response
Wed May 30 05:00:41 UTC 2018 : Method completed with status: 502

This is a rather cryptic message, but  it’s saying is the response is not in the expected format.

Per this doc, the expected response should be in this format:

    "isBase64Encoded": true|false,
    "statusCode": httpStatusCode,
    "headers": { "headerName": "headerValue", ... },
    "body": "..."

AWS Lambda node.js template

The node.js based implementation of AWS Lambdas has the following structure:

Using ES6 fat arrow syntax:

exports.handlerName = (event, context, callback) => {
  callback(error, result);

where error is either null for a successful execution, or an error, and result is a response to return to your caller.

Using ES5 syntax:

exports.handlerName = function(event, context, callback) {
  callback(error, result);

For more info, see here.

Game development in progress: Space Invaders clone – update 3 (18 months later)

It’s been a year and a half since I’ve given an update on my Space Invaders clone on Android. Admittedly I haven’t been working continuously in my spare time on this project for 18 months, in fact the last time I remember working on it was several months back. What I got stuck on was updating the animation routines so the animation would display with a constant frame rate across different Android devices, and the display of the sprites to look consistent for devices with different sized screens, resolutions and pixel densities.

If you’re a seasoned game developer this is probably nothing new to you. If you only develop for a platform with identical hardware specs (like a game console) then this is probably something you don’t have to worry (too much?) about. However with the broad range of specs for Android devices, even testing with the device emulator for different phones, it’s pretty obvious unless your code handles these differences, your game might be fast on one device but slow on another, or the sprite layout may look at intended at the resolution on one phone but be too small on another phone.

I spent a bunch of time reading game dev articles about implementing approaches for constant frame rates, and tried to incorporate what I’d learned, but still, I’ve got some weird quirks I need to iron out.

Here’s what the game looks like on an emulated Pixel:

I was initially developing and testing on the emulated Nexus devices as my baseline test target, but it runs fine, as expected on the Pixel too (it’s harder to play when pressing the buttons with the mouse!).

Now running on an emulated Pixel 2 XL, it runs fine for a while until the number of invaders gets down to where I speed up. The speed up is too fast, and then for some reason that I haven’t found yet they animation stops before the game ends but the game is still playing:
Clearly I’ve still got some work to do here, but it’s getting close.

Installing OS/2 4.52 (Warp 4) on VMware ESXI

Installers with floppy disk boot images require swapping the disk images which is tedious. Find ISO images with 1 boot CDROM ISO and 1 install CDROM ISO – this is a much easier approach for installing. The Boot ISO and English ISO from this collection on work well.

Create a VM with:

  • 1 vCPU
  • 32MB RAM
  • 500MB disk

In ESXi this looks like:

Attach the iso boot image and boot the VM:

Remove the boot ISO cdrom and switch to the English language cdrom the press Enter:

F5 to switch to Physical View:

Tab to the [free space] in the second section, press Enter for Options, and create new Primary partition:

Press F5 to change back to Logical View, press Enter for Options:

Haven’t created or selected a logical volume, this forces you back to the Logical Volume Manager:

Choose the physical partition we created:

Now this looks like:

Set the volume to be installable:

Switch the ISO image back to the boot ISO and restart the VM.

On restarting the VM, with ESXi for some reason it changes the boot order at this point to the HD first, CDROM image second, so you’ll get a blank black screen on startup.

Power off the VM.

Go into your VM options and check the option to force boot to BIOS on next start:

Power on again.

When the BIOS menu comes up, go to Boot and change the CDROM entry to it is first in the list with the + key, then Save and Exit:

When booted, swap CDROM ISO image to the second install ISO when prompted.

You’ll now see the Welcome install screen again. Enter through the next few screens until you get to the partition selection screen, Accept the partition we created earlier and do a ‘Quick format’ when prompted:

Select HPFS:

The install from the ISO image goes pretty quick, then you’ll see this screen:

Followed by a reboot. You’ll now see the first of the config option dialogs:

You can leave the graphics as default, or press the button and switch the the GRADD drivers (which from memory are the better drivers to use):

Next/Ok through the the next few screens, then you’ll get to the optional installs:

I left the selected options, press Next:

Complete the registration screen, and then you get more options, I unchecked File and Print Sharing, and left the other pre-selected options:

Press Next, if there’s anything that needs additional config it will be flagged here, otherwise press Install:

The install goes pretty quick from here and will reboot at least once:

“IBM Means 3 Things”:

After another reboot if you get a blank screen with network card info, press Enter to continue then you’ll get to your desktop with more options – I selected Java 1.3 to take a look, and the IBM Web Browser:

At this point the installer doesn’t see my CDROM image even though it’s attached, but pressing Exit take me to the desktop.

Welcome to OS/2 Warp 4:

The network adapter wasn’t configured with DHCP by default, so from the TCP/IP folder on the desktop, find TCP/IP Configuration (Local) and enable the first interface and DHCP:

You’ll be prompted to reboot again, but now you should have an IP, and if you open Netscape, you’ll be able to browse the web, although with some rendering issues for sites using features not supported in this older version of Netscape.